1 package org
.asamk
.signal
.manager
.actions
;
3 import org
.asamk
.signal
.manager
.helper
.Context
;
4 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientId
;
5 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceReceiptMessage
;
7 import java
.util
.ArrayList
;
9 import java
.util
.Objects
;
11 public class SendReceiptAction
implements HandleAction
{
13 private final RecipientId recipientId
;
14 private final SignalServiceReceiptMessage
.Type type
;
15 private final List
<Long
> timestamps
= new ArrayList
<>();
17 public SendReceiptAction(
18 final RecipientId recipientId
,
19 final SignalServiceReceiptMessage
.Type type
,
22 this.recipientId
= recipientId
;
24 this.timestamps
.add(timestamp
);
28 public void execute(Context context
) throws Throwable
{
29 final var receiptMessage
= new SignalServiceReceiptMessage(type
, timestamps
, System
.currentTimeMillis());
31 context
.getSendHelper().sendReceiptMessage(receiptMessage
, recipientId
);
35 public void mergeOther(final HandleAction action
) {
36 if (action
instanceof SendReceiptAction sendReceiptAction
) {
37 this.timestamps
.addAll(sendReceiptAction
.timestamps
);
42 public boolean equals(final Object o
) {
43 if (this == o
) return true;
44 if (o
== null || getClass() != o
.getClass()) return false;
45 final SendReceiptAction that
= (SendReceiptAction
) o
;
46 // Using only recipientId and type here on purpose
47 return recipientId
.equals(that
.recipientId
) && type
== that
.type
;
51 public int hashCode() {
52 // Using only recipientId and type here on purpose
53 return Objects
.hash(recipientId
, type
);