mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Extract getSelfProfile method
This commit is contained in:
parent
a80e18169a
commit
35679216f7
4 changed files with 8 additions and 5 deletions
|
@ -130,8 +130,7 @@ public final class IncomingMessageHandler {
|
||||||
logger.debug("Received invalid message from blocked contact, ignoring.");
|
logger.debug("Received invalid message from blocked contact, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
final var senderProfile = context.getProfileHelper().getRecipientProfile(sender);
|
final var senderProfile = context.getProfileHelper().getRecipientProfile(sender);
|
||||||
final var selfProfile = context.getProfileHelper()
|
final var selfProfile = context.getProfileHelper().getSelfProfile();
|
||||||
.getRecipientProfile(account.getSelfRecipientId());
|
|
||||||
if ((!sender.equals(account.getSelfRecipientId()) || e.getSenderDevice() != account.getDeviceId())
|
if ((!sender.equals(account.getSelfRecipientId()) || e.getSenderDevice() != account.getDeviceId())
|
||||||
&& senderProfile != null
|
&& senderProfile != null
|
||||||
&& senderProfile.getCapabilities().contains(Profile.Capability.senderKey)
|
&& senderProfile.getCapabilities().contains(Profile.Capability.senderKey)
|
||||||
|
|
|
@ -114,7 +114,7 @@ public final class ProfileHelper {
|
||||||
String aboutEmoji,
|
String aboutEmoji,
|
||||||
Optional<File> avatar
|
Optional<File> avatar
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var profile = getRecipientProfile(account.getSelfRecipientId());
|
var profile = getSelfProfile();
|
||||||
var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
|
var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
|
||||||
if (givenName != null) {
|
if (givenName != null) {
|
||||||
builder.withGivenName(givenName);
|
builder.withGivenName(givenName);
|
||||||
|
@ -164,6 +164,10 @@ public final class ProfileHelper {
|
||||||
account.getProfileStore().storeProfile(account.getSelfRecipientId(), newProfile);
|
account.getProfileStore().storeProfile(account.getSelfRecipientId(), newProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Profile getSelfProfile() {
|
||||||
|
return getRecipientProfile(account.getSelfRecipientId());
|
||||||
|
}
|
||||||
|
|
||||||
public List<Profile> getRecipientProfile(List<RecipientId> recipientIds) {
|
public List<Profile> getRecipientProfile(List<RecipientId> recipientIds) {
|
||||||
try {
|
try {
|
||||||
account.getRecipientStore().setBulkUpdating(true);
|
account.getRecipientStore().setBulkUpdating(true);
|
||||||
|
|
|
@ -441,7 +441,7 @@ public class SendHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<RecipientId> getSenderKeyCapableRecipientIds(final Set<RecipientId> recipientIds) {
|
private Set<RecipientId> getSenderKeyCapableRecipientIds(final Set<RecipientId> recipientIds) {
|
||||||
final var selfProfile = context.getProfileHelper().getRecipientProfile(account.getSelfRecipientId());
|
final var selfProfile = context.getProfileHelper().getSelfProfile();
|
||||||
if (selfProfile == null || !selfProfile.getCapabilities().contains(Profile.Capability.senderKey)) {
|
if (selfProfile == null || !selfProfile.getCapabilities().contains(Profile.Capability.senderKey)) {
|
||||||
logger.debug("Not all of our devices support sender key. Using legacy.");
|
logger.debug("Not all of our devices support sender key. Using legacy.");
|
||||||
return Set.of();
|
return Set.of();
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class UnidentifiedAccessHelper {
|
||||||
private byte[] getSelfUnidentifiedAccessKey(boolean noRefresh) {
|
private byte[] getSelfUnidentifiedAccessKey(boolean noRefresh) {
|
||||||
var selfProfile = noRefresh
|
var selfProfile = noRefresh
|
||||||
? account.getProfileStore().getProfile(account.getSelfRecipientId())
|
? account.getProfileStore().getProfile(account.getSelfRecipientId())
|
||||||
: context.getProfileHelper().getRecipientProfile(account.getSelfRecipientId());
|
: context.getProfileHelper().getSelfProfile();
|
||||||
if (selfProfile != null
|
if (selfProfile != null
|
||||||
&& selfProfile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNRESTRICTED) {
|
&& selfProfile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNRESTRICTED) {
|
||||||
return createUnrestrictedUnidentifiedAccess();
|
return createUnrestrictedUnidentifiedAccess();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue