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
;
8 import java
.util
.Objects
;
10 interface HandleAction
{
12 void execute(Manager m
) throws Throwable
;
15 class SendReceiptAction
implements HandleAction
{
17 private final SignalServiceAddress address
;
18 private final long timestamp
;
20 public SendReceiptAction(final SignalServiceAddress address
, final long timestamp
) {
21 this.address
= address
;
22 this.timestamp
= timestamp
;
26 public void execute(Manager m
) throws Throwable
{
27 m
.sendDeliveryReceipt(address
, List
.of(timestamp
));
31 public boolean equals(final Object o
) {
32 if (this == o
) return true;
33 if (o
== null || getClass() != o
.getClass()) return false;
34 final var that
= (SendReceiptAction
) o
;
35 return timestamp
== that
.timestamp
&& address
.equals(that
.address
);
39 public int hashCode() {
40 return Objects
.hash(address
, timestamp
);
44 class SendSyncContactsAction
implements HandleAction
{
46 private static final SendSyncContactsAction INSTANCE
= new SendSyncContactsAction();
48 private SendSyncContactsAction() {
51 public static SendSyncContactsAction
create() {
56 public void execute(Manager m
) throws Throwable
{
61 class SendSyncGroupsAction
implements HandleAction
{
63 private static final SendSyncGroupsAction INSTANCE
= new SendSyncGroupsAction();
65 private SendSyncGroupsAction() {
68 public static SendSyncGroupsAction
create() {
73 public void execute(Manager m
) throws Throwable
{
78 class SendSyncBlockedListAction
implements HandleAction
{
80 private static final SendSyncBlockedListAction INSTANCE
= new SendSyncBlockedListAction();
82 private SendSyncBlockedListAction() {
85 public static SendSyncBlockedListAction
create() {
90 public void execute(Manager m
) throws Throwable
{
95 class SendGroupInfoRequestAction
implements HandleAction
{
97 private final SignalServiceAddress address
;
98 private final GroupIdV1 groupId
;
100 public SendGroupInfoRequestAction(final SignalServiceAddress address
, final GroupIdV1 groupId
) {
101 this.address
= address
;
102 this.groupId
= groupId
;
106 public void execute(Manager m
) throws Throwable
{
107 m
.sendGroupInfoRequest(groupId
, address
);
111 public boolean equals(final Object o
) {
112 if (this == o
) return true;
113 if (o
== null || getClass() != o
.getClass()) return false;
115 final var that
= (SendGroupInfoRequestAction
) o
;
117 if (!address
.equals(that
.address
)) return false;
118 return groupId
.equals(that
.groupId
);
122 public int hashCode() {
123 var result
= address
.hashCode();
124 result
= 31 * result
+ groupId
.hashCode();
129 class SendGroupInfoAction
implements HandleAction
{
131 private final SignalServiceAddress address
;
132 private final GroupIdV1 groupId
;
134 public SendGroupInfoAction(final SignalServiceAddress address
, final GroupIdV1 groupId
) {
135 this.address
= address
;
136 this.groupId
= groupId
;
140 public void execute(Manager m
) throws Throwable
{
141 m
.sendGroupInfoMessage(groupId
, address
);
145 public boolean equals(final Object o
) {
146 if (this == o
) return true;
147 if (o
== null || getClass() != o
.getClass()) return false;
149 final var that
= (SendGroupInfoAction
) o
;
151 if (!address
.equals(that
.address
)) return false;
152 return groupId
.equals(that
.groupId
);
156 public int hashCode() {
157 var result
= address
.hashCode();
158 result
= 31 * result
+ groupId
.hashCode();
163 class RetrieveProfileAction
implements HandleAction
{
165 private final RecipientId recipientId
;
167 public RetrieveProfileAction(final RecipientId recipientId
) {
168 this.recipientId
= recipientId
;
172 public void execute(Manager m
) throws Throwable
{
173 m
.refreshRecipientProfile(recipientId
);
177 public boolean equals(final Object o
) {
178 if (this == o
) return true;
179 if (o
== null || getClass() != o
.getClass()) return false;
181 final RetrieveProfileAction that
= (RetrieveProfileAction
) o
;
183 return recipientId
.equals(that
.recipientId
);
187 public int hashCode() {
188 return recipientId
.hashCode();
192 class RenewSessionAction
implements HandleAction
{
194 private final RecipientId recipientId
;
196 public RenewSessionAction(final RecipientId recipientId
) {
197 this.recipientId
= recipientId
;
201 public void execute(Manager m
) throws Throwable
{
202 m
.renewSession(recipientId
);
206 public boolean equals(final Object o
) {
207 if (this == o
) return true;
208 if (o
== null || getClass() != o
.getClass()) return false;
210 final RenewSessionAction that
= (RenewSessionAction
) o
;
212 return recipientId
.equals(that
.recipientId
);
216 public int hashCode() {
217 return recipientId
.hashCode();