1 package org
.asamk
.signal
.manager
;
3 import org
.asamk
.signal
.manager
.groups
.GroupIdV1
;
4 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientId
;
5 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
7 import java
.util
.Objects
;
9 interface HandleAction
{
11 void execute(Manager m
) throws Throwable
;
14 class SendReceiptAction
implements HandleAction
{
16 private final SignalServiceAddress address
;
17 private final long timestamp
;
19 public SendReceiptAction(final SignalServiceAddress address
, final long timestamp
) {
20 this.address
= address
;
21 this.timestamp
= timestamp
;
25 public void execute(Manager m
) throws Throwable
{
26 m
.sendReceipt(address
, timestamp
);
30 public boolean equals(final Object o
) {
31 if (this == o
) return true;
32 if (o
== null || getClass() != o
.getClass()) return false;
33 final var that
= (SendReceiptAction
) o
;
34 return timestamp
== that
.timestamp
&& address
.equals(that
.address
);
38 public int hashCode() {
39 return Objects
.hash(address
, timestamp
);
43 class SendSyncContactsAction
implements HandleAction
{
45 private static final SendSyncContactsAction INSTANCE
= new SendSyncContactsAction();
47 private SendSyncContactsAction() {
50 public static SendSyncContactsAction
create() {
55 public void execute(Manager m
) throws Throwable
{
60 class SendSyncGroupsAction
implements HandleAction
{
62 private static final SendSyncGroupsAction INSTANCE
= new SendSyncGroupsAction();
64 private SendSyncGroupsAction() {
67 public static SendSyncGroupsAction
create() {
72 public void execute(Manager m
) throws Throwable
{
77 class SendSyncBlockedListAction
implements HandleAction
{
79 private static final SendSyncBlockedListAction INSTANCE
= new SendSyncBlockedListAction();
81 private SendSyncBlockedListAction() {
84 public static SendSyncBlockedListAction
create() {
89 public void execute(Manager m
) throws Throwable
{
94 class SendGroupInfoRequestAction
implements HandleAction
{
96 private final SignalServiceAddress address
;
97 private final GroupIdV1 groupId
;
99 public SendGroupInfoRequestAction(final SignalServiceAddress address
, final GroupIdV1 groupId
) {
100 this.address
= address
;
101 this.groupId
= groupId
;
105 public void execute(Manager m
) throws Throwable
{
106 m
.sendGroupInfoRequest(groupId
, address
);
110 public boolean equals(final Object o
) {
111 if (this == o
) return true;
112 if (o
== null || getClass() != o
.getClass()) return false;
114 final var that
= (SendGroupInfoRequestAction
) o
;
116 if (!address
.equals(that
.address
)) return false;
117 return groupId
.equals(that
.groupId
);
121 public int hashCode() {
122 var result
= address
.hashCode();
123 result
= 31 * result
+ groupId
.hashCode();
128 class SendGroupInfoAction
implements HandleAction
{
130 private final SignalServiceAddress address
;
131 private final GroupIdV1 groupId
;
133 public SendGroupInfoAction(final SignalServiceAddress address
, final GroupIdV1 groupId
) {
134 this.address
= address
;
135 this.groupId
= groupId
;
139 public void execute(Manager m
) throws Throwable
{
140 m
.sendGroupInfoMessage(groupId
, address
);
144 public boolean equals(final Object o
) {
145 if (this == o
) return true;
146 if (o
== null || getClass() != o
.getClass()) return false;
148 final var that
= (SendGroupInfoAction
) o
;
150 if (!address
.equals(that
.address
)) return false;
151 return groupId
.equals(that
.groupId
);
155 public int hashCode() {
156 var result
= address
.hashCode();
157 result
= 31 * result
+ groupId
.hashCode();
162 class RetrieveProfileAction
implements HandleAction
{
164 private final RecipientId recipientId
;
166 public RetrieveProfileAction(final RecipientId recipientId
) {
167 this.recipientId
= recipientId
;
171 public void execute(Manager m
) throws Throwable
{
172 m
.getRecipientProfile(recipientId
, true);
176 public boolean equals(final Object o
) {
177 if (this == o
) return true;
178 if (o
== null || getClass() != o
.getClass()) return false;
180 final RetrieveProfileAction that
= (RetrieveProfileAction
) o
;
182 return recipientId
.equals(that
.recipientId
);
186 public int hashCode() {
187 return recipientId
.hashCode();