mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Refresh prekeys after receiving a pre key message, if necessary
This commit is contained in:
parent
2196ac6975
commit
e3d5ebaa9e
4 changed files with 38 additions and 3 deletions
|
@ -227,7 +227,8 @@ public class Manager implements Closeable {
|
||||||
groupHelper,
|
groupHelper,
|
||||||
syncHelper,
|
syncHelper,
|
||||||
profileHelper,
|
profileHelper,
|
||||||
storageHelper);
|
storageHelper,
|
||||||
|
preKeyHelper);
|
||||||
var jobExecutor = new JobExecutor(context);
|
var jobExecutor = new JobExecutor(context);
|
||||||
|
|
||||||
this.incomingMessageHandler = new IncomingMessageHandler(account,
|
this.incomingMessageHandler = new IncomingMessageHandler(account,
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.asamk.signal.manager.actions;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.jobs.Context;
|
||||||
|
|
||||||
|
public class RefreshPreKeysAction implements HandleAction {
|
||||||
|
|
||||||
|
private static final RefreshPreKeysAction INSTANCE = new RefreshPreKeysAction();
|
||||||
|
|
||||||
|
private RefreshPreKeysAction() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RefreshPreKeysAction create() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(Context context) throws Throwable {
|
||||||
|
context.getPreKeyHelper().refreshPreKeysIfNecessary();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.TrustLevel;
|
import org.asamk.signal.manager.TrustLevel;
|
||||||
import org.asamk.signal.manager.UntrustedIdentityException;
|
import org.asamk.signal.manager.UntrustedIdentityException;
|
||||||
import org.asamk.signal.manager.actions.HandleAction;
|
import org.asamk.signal.manager.actions.HandleAction;
|
||||||
|
import org.asamk.signal.manager.actions.RefreshPreKeysAction;
|
||||||
import org.asamk.signal.manager.actions.RenewSessionAction;
|
import org.asamk.signal.manager.actions.RenewSessionAction;
|
||||||
import org.asamk.signal.manager.actions.RetrieveProfileAction;
|
import org.asamk.signal.manager.actions.RetrieveProfileAction;
|
||||||
import org.asamk.signal.manager.actions.RetrieveStorageDataAction;
|
import org.asamk.signal.manager.actions.RetrieveStorageDataAction;
|
||||||
|
@ -87,6 +88,11 @@ public final class IncomingMessageHandler {
|
||||||
final boolean ignoreAttachments,
|
final boolean ignoreAttachments,
|
||||||
final Manager.ReceiveMessageHandler handler
|
final Manager.ReceiveMessageHandler handler
|
||||||
) {
|
) {
|
||||||
|
final List<HandleAction> actions = new ArrayList<>();
|
||||||
|
if (envelope.isPreKeySignalMessage()) {
|
||||||
|
actions.add(RefreshPreKeysAction.create());
|
||||||
|
}
|
||||||
|
|
||||||
SignalServiceContent content = null;
|
SignalServiceContent content = null;
|
||||||
if (!envelope.isReceipt()) {
|
if (!envelope.isReceipt()) {
|
||||||
try {
|
try {
|
||||||
|
@ -100,7 +106,7 @@ public final class IncomingMessageHandler {
|
||||||
return new Pair<>(List.of(), e);
|
return new Pair<>(List.of(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final var actions = checkAndHandleMessage(envelope, content, ignoreAttachments, handler, null);
|
actions.addAll(checkAndHandleMessage(envelope, content, ignoreAttachments, handler, null));
|
||||||
return new Pair<>(actions, null);
|
return new Pair<>(actions, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.manager.jobs;
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.StickerPackStore;
|
import org.asamk.signal.manager.StickerPackStore;
|
||||||
import org.asamk.signal.manager.helper.GroupHelper;
|
import org.asamk.signal.manager.helper.GroupHelper;
|
||||||
|
import org.asamk.signal.manager.helper.PreKeyHelper;
|
||||||
import org.asamk.signal.manager.helper.ProfileHelper;
|
import org.asamk.signal.manager.helper.ProfileHelper;
|
||||||
import org.asamk.signal.manager.helper.SendHelper;
|
import org.asamk.signal.manager.helper.SendHelper;
|
||||||
import org.asamk.signal.manager.helper.StorageHelper;
|
import org.asamk.signal.manager.helper.StorageHelper;
|
||||||
|
@ -19,6 +20,7 @@ public class Context {
|
||||||
private final SyncHelper syncHelper;
|
private final SyncHelper syncHelper;
|
||||||
private final ProfileHelper profileHelper;
|
private final ProfileHelper profileHelper;
|
||||||
private final StorageHelper storageHelper;
|
private final StorageHelper storageHelper;
|
||||||
|
private final PreKeyHelper preKeyHelper;
|
||||||
|
|
||||||
public Context(
|
public Context(
|
||||||
final SignalAccount account,
|
final SignalAccount account,
|
||||||
|
@ -28,7 +30,8 @@ public class Context {
|
||||||
final GroupHelper groupHelper,
|
final GroupHelper groupHelper,
|
||||||
final SyncHelper syncHelper,
|
final SyncHelper syncHelper,
|
||||||
final ProfileHelper profileHelper,
|
final ProfileHelper profileHelper,
|
||||||
final StorageHelper storageHelper
|
final StorageHelper storageHelper,
|
||||||
|
final PreKeyHelper preKeyHelper
|
||||||
) {
|
) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.dependencies = dependencies;
|
this.dependencies = dependencies;
|
||||||
|
@ -38,6 +41,7 @@ public class Context {
|
||||||
this.syncHelper = syncHelper;
|
this.syncHelper = syncHelper;
|
||||||
this.profileHelper = profileHelper;
|
this.profileHelper = profileHelper;
|
||||||
this.storageHelper = storageHelper;
|
this.storageHelper = storageHelper;
|
||||||
|
this.preKeyHelper = preKeyHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalAccount getAccount() {
|
public SignalAccount getAccount() {
|
||||||
|
@ -71,4 +75,8 @@ public class Context {
|
||||||
public StorageHelper getStorageHelper() {
|
public StorageHelper getStorageHelper() {
|
||||||
return storageHelper;
|
return storageHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PreKeyHelper getPreKeyHelper() {
|
||||||
|
return preKeyHelper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue