From 5cac7feabed779eaea48f95ab82939f26854c1e9 Mon Sep 17 00:00:00 2001 From: AsamK Date: Sun, 12 Nov 2023 12:12:02 +0100 Subject: [PATCH] Add who am I job --- .../signal/manager/helper/StorageHelper.java | 3 ++- .../signal/manager/jobs/CheckWhoAmIJob.java | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 lib/src/main/java/org/asamk/signal/manager/jobs/CheckWhoAmIJob.java diff --git a/lib/src/main/java/org/asamk/signal/manager/helper/StorageHelper.java b/lib/src/main/java/org/asamk/signal/manager/helper/StorageHelper.java index 393953d9..fa1eef11 100644 --- a/lib/src/main/java/org/asamk/signal/manager/helper/StorageHelper.java +++ b/lib/src/main/java/org/asamk/signal/manager/helper/StorageHelper.java @@ -6,6 +6,7 @@ import org.asamk.signal.manager.api.PhoneNumberSharingMode; import org.asamk.signal.manager.api.Profile; import org.asamk.signal.manager.api.TrustLevel; import org.asamk.signal.manager.internal.SignalDependencies; +import org.asamk.signal.manager.jobs.CheckWhoAmIJob; import org.asamk.signal.manager.jobs.DownloadProfileAvatarJob; import org.asamk.signal.manager.storage.SignalAccount; import org.asamk.signal.manager.storage.recipients.RecipientAddress; @@ -251,7 +252,7 @@ public class StorageHelper { } if (!accountRecord.getE164().equals(account.getNumber())) { - context.getAccountHelper().checkWhoAmiI(); + context.getJobExecutor().enqueueJob(new CheckWhoAmIJob()); } account.getConfigurationStore().setReadReceipts(accountRecord.isReadReceiptsEnabled()); diff --git a/lib/src/main/java/org/asamk/signal/manager/jobs/CheckWhoAmIJob.java b/lib/src/main/java/org/asamk/signal/manager/jobs/CheckWhoAmIJob.java new file mode 100644 index 00000000..165bf70e --- /dev/null +++ b/lib/src/main/java/org/asamk/signal/manager/jobs/CheckWhoAmIJob.java @@ -0,0 +1,22 @@ +package org.asamk.signal.manager.jobs; + +import org.asamk.signal.manager.helper.Context; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; + +public class CheckWhoAmIJob implements Job { + + private static final Logger logger = LoggerFactory.getLogger(CheckWhoAmIJob.class); + + @Override + public void run(Context context) { + logger.trace("Checking whoAmI"); + try { + context.getAccountHelper().checkWhoAmiI(); + } catch (IOException e) { + logger.warn("Failed to check whoAmI", e); + } + } +}