mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add download profile avatar job
This commit is contained in:
parent
ed11bf6368
commit
d844e0f396
2 changed files with 25 additions and 1 deletions
|
@ -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.DownloadProfileAvatarJob;
|
||||
import org.asamk.signal.manager.storage.SignalAccount;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||
import org.signal.libsignal.protocol.IdentityKey;
|
||||
|
@ -276,7 +277,7 @@ public class StorageHelper {
|
|||
if (profileKey != null) {
|
||||
account.setProfileKey(profileKey);
|
||||
final var avatarPath = accountRecord.getAvatarUrlPath().orElse(null);
|
||||
context.getProfileHelper().downloadProfileAvatar(account.getSelfRecipientId(), avatarPath, profileKey);
|
||||
context.getJobExecutor().enqueueJob(new DownloadProfileAvatarJob(avatarPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package org.asamk.signal.manager.jobs;
|
||||
|
||||
import org.asamk.signal.manager.helper.Context;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DownloadProfileAvatarJob implements Job {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DownloadProfileAvatarJob.class);
|
||||
private final String avatarPath;
|
||||
|
||||
public DownloadProfileAvatarJob(final String avatarPath) {
|
||||
this.avatarPath = avatarPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Context context) {
|
||||
logger.trace("Downloading profile avatar {}", avatarPath);
|
||||
final var account = context.getAccount();
|
||||
context.getProfileHelper()
|
||||
.downloadProfileAvatar(account.getSelfRecipientId(), avatarPath, account.getProfileKey());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue