mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Enable profile sharing when accepting message request
This commit is contained in:
parent
3b3377e6e9
commit
9051f68ba6
2 changed files with 15 additions and 4 deletions
|
@ -49,6 +49,13 @@ public class ContactHelper {
|
|||
account.getContactStore().storeContact(recipientId, builder.withIsBlocked(blocked).build());
|
||||
}
|
||||
|
||||
public void setContactProfileSharing(RecipientId recipientId, boolean profileSharing) {
|
||||
var contact = account.getContactStore().getContact(recipientId);
|
||||
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
||||
builder.withIsProfileSharingEnabled(profileSharing);
|
||||
account.getContactStore().storeContact(recipientId, builder.build());
|
||||
}
|
||||
|
||||
public void setContactHidden(RecipientId recipientId, boolean hidden) {
|
||||
var contact = account.getContactStore().getContact(recipientId);
|
||||
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.asamk.signal.manager.helper;
|
|||
|
||||
import org.asamk.signal.manager.api.Contact;
|
||||
import org.asamk.signal.manager.api.GroupId;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope.Sync.MessageRequestResponse;
|
||||
import org.asamk.signal.manager.api.TrustLevel;
|
||||
import org.asamk.signal.manager.storage.SignalAccount;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfoV1;
|
||||
|
@ -368,19 +368,23 @@ public class SyncHelper {
|
|||
}
|
||||
|
||||
public SendMessageResult sendMessageRequestResponse(
|
||||
final MessageEnvelope.Sync.MessageRequestResponse.Type type, final GroupId groupId
|
||||
final MessageRequestResponse.Type type, final GroupId groupId
|
||||
) {
|
||||
final var response = MessageRequestResponseMessage.forGroup(groupId.serialize(), localToRemoteType(type));
|
||||
return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forMessageRequestResponse(response));
|
||||
}
|
||||
|
||||
public SendMessageResult sendMessageRequestResponse(
|
||||
final MessageEnvelope.Sync.MessageRequestResponse.Type type, final RecipientId recipientId
|
||||
final MessageRequestResponse.Type type, final RecipientId recipientId
|
||||
) {
|
||||
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
|
||||
if (address.serviceId().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
context.getContactHelper()
|
||||
.setContactProfileSharing(recipientId,
|
||||
type == MessageRequestResponse.Type.ACCEPT
|
||||
|| type == MessageRequestResponse.Type.UNBLOCK_AND_ACCEPT);
|
||||
final var response = MessageRequestResponseMessage.forIndividual(address.serviceId().get(),
|
||||
localToRemoteType(type));
|
||||
return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forMessageRequestResponse(response));
|
||||
|
@ -411,7 +415,7 @@ public class SyncHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private MessageRequestResponseMessage.Type localToRemoteType(final MessageEnvelope.Sync.MessageRequestResponse.Type type) {
|
||||
private MessageRequestResponseMessage.Type localToRemoteType(final MessageRequestResponse.Type type) {
|
||||
return switch (type) {
|
||||
case UNKNOWN -> MessageRequestResponseMessage.Type.UNKNOWN;
|
||||
case ACCEPT -> MessageRequestResponseMessage.Type.ACCEPT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue