]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/actions/SendGroupInfoAction.java
Extract ContactHelper and IncomingMessageHandler
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / actions / SendGroupInfoAction.java
diff --git a/lib/src/main/java/org/asamk/signal/manager/actions/SendGroupInfoAction.java b/lib/src/main/java/org/asamk/signal/manager/actions/SendGroupInfoAction.java
new file mode 100644 (file)
index 0000000..6f66cee
--- /dev/null
@@ -0,0 +1,39 @@
+package org.asamk.signal.manager.actions;
+
+import org.asamk.signal.manager.groups.GroupIdV1;
+import org.asamk.signal.manager.jobs.Context;
+import org.asamk.signal.manager.storage.recipients.RecipientId;
+
+public class SendGroupInfoAction implements HandleAction {
+
+    private final RecipientId recipientId;
+    private final GroupIdV1 groupId;
+
+    public SendGroupInfoAction(final RecipientId recipientId, final GroupIdV1 groupId) {
+        this.recipientId = recipientId;
+        this.groupId = groupId;
+    }
+
+    @Override
+    public void execute(Context context) throws Throwable {
+        context.getGroupHelper().sendGroupInfoMessage(groupId, recipientId);
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final var that = (SendGroupInfoAction) o;
+
+        if (!recipientId.equals(that.recipientId)) return false;
+        return groupId.equals(that.groupId);
+    }
+
+    @Override
+    public int hashCode() {
+        var result = recipientId.hashCode();
+        result = 31 * result + groupId.hashCode();
+        return result;
+    }
+}