Update profile sharing when added to group
This commit is contained in:
parent
5e44de3bd7
commit
435dc2acf7
3 changed files with 35 additions and 38 deletions
12
ts/groups.ts
12
ts/groups.ts
|
@ -105,7 +105,10 @@ import { generateMessageId } from './util/generateMessageId';
|
||||||
import { postSaveUpdates } from './util/cleanup';
|
import { postSaveUpdates } from './util/cleanup';
|
||||||
import { MessageModel } from './models/messages';
|
import { MessageModel } from './models/messages';
|
||||||
import { areWePending } from './util/groupMembershipUtils';
|
import { areWePending } from './util/groupMembershipUtils';
|
||||||
import { isConversationAccepted } from './util/isConversationAccepted';
|
import {
|
||||||
|
isConversationAccepted,
|
||||||
|
isTrustedContact,
|
||||||
|
} from './util/isConversationAccepted';
|
||||||
|
|
||||||
const log = createLogger('groups');
|
const log = createLogger('groups');
|
||||||
|
|
||||||
|
@ -3277,6 +3280,13 @@ async function updateGroup(
|
||||||
// Return early to discard group changes resulting from unwanted group add
|
// Return early to discard group changes resulting from unwanted group add
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adder && isTrustedContact(adder?.attributes)) {
|
||||||
|
conversation.enableProfileSharing({
|
||||||
|
reason: 'addedToGroupByTrustedContact',
|
||||||
|
viaStorageServiceSync: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We update group membership last to ensure that all notifications are in place before
|
// We update group membership last to ensure that all notifications are in place before
|
||||||
|
|
|
@ -4185,29 +4185,6 @@ export class ConversationModel {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this someone who is a contact, or are we sharing our profile with them?
|
|
||||||
// Or is the person who added us to this group a contact or are we sharing profile
|
|
||||||
// with them?
|
|
||||||
isFromOrAddedByTrustedContact(): boolean {
|
|
||||||
if (isDirectConversation(this.attributes)) {
|
|
||||||
return Boolean(this.get('name')) || Boolean(this.get('profileSharing'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const addedBy = this.get('addedBy');
|
|
||||||
if (!addedBy) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const conv = window.ConversationController.get(addedBy);
|
|
||||||
if (!conv) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Boolean(
|
|
||||||
isMe(conv.attributes) || conv.get('name') || conv.get('profileSharing')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async maybeClearUsername(): Promise<void> {
|
async maybeClearUsername(): Promise<void> {
|
||||||
const ourConversationId =
|
const ourConversationId =
|
||||||
window.ConversationController.getOurConversationId();
|
window.ConversationController.getOurConversationId();
|
||||||
|
|
|
@ -5,11 +5,14 @@ import type { ConversationAttributesType } from '../model-types.d';
|
||||||
import { SignalService as Proto } from '../protobuf';
|
import { SignalService as Proto } from '../protobuf';
|
||||||
import { isDirectConversation, isMe } from './whatTypeOfConversation';
|
import { isDirectConversation, isMe } from './whatTypeOfConversation';
|
||||||
import { isInSystemContacts } from './isInSystemContacts';
|
import { isInSystemContacts } from './isInSystemContacts';
|
||||||
|
import { createLogger } from '../logging/log';
|
||||||
|
|
||||||
export type IsConversationAcceptedOptionsType = {
|
export type IsConversationAcceptedOptionsType = {
|
||||||
ignoreEmptyConvo: boolean;
|
ignoreEmptyConvo: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const log = createLogger('isConversationAccepted');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this conversation should be considered "accepted" in terms
|
* Determine if this conversation should be considered "accepted" in terms
|
||||||
* of message requests
|
* of message requests
|
||||||
|
@ -77,17 +80,28 @@ export function isConversationAccepted(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this someone who is a contact, or are we sharing our profile with them?
|
// Is this someone me, a system contact, or are we sharing our profile with them?
|
||||||
// Or is the person who added us to this group a contact or are we sharing profile
|
export function isTrustedContact(
|
||||||
// with them?
|
conversationAttrs: ConversationAttributesType
|
||||||
|
): boolean {
|
||||||
|
if (!isDirectConversation(conversationAttrs)) {
|
||||||
|
log.error('isTrustedContact should only be called for direct convos');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
isMe(conversationAttrs) ||
|
||||||
|
isInSystemContacts(conversationAttrs) ||
|
||||||
|
Boolean(conversationAttrs.profileSharing)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is this person (or the person who added us to this group) a trusted contact?
|
||||||
function isFromOrAddedByTrustedContact(
|
function isFromOrAddedByTrustedContact(
|
||||||
conversationAttrs: ConversationAttributesType
|
conversationAttrs: ConversationAttributesType
|
||||||
): boolean {
|
): boolean {
|
||||||
if (isDirectConversation(conversationAttrs)) {
|
if (isDirectConversation(conversationAttrs)) {
|
||||||
return (
|
return isTrustedContact(conversationAttrs);
|
||||||
isInSystemContacts(conversationAttrs) ||
|
|
||||||
Boolean(conversationAttrs.profileSharing)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { addedBy } = conversationAttrs;
|
const { addedBy } = conversationAttrs;
|
||||||
|
@ -95,14 +109,10 @@ function isFromOrAddedByTrustedContact(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const conversation = window.ConversationController.get(addedBy);
|
const addedByContact = window.ConversationController.get(addedBy);
|
||||||
if (!conversation) {
|
if (!addedByContact) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Boolean(
|
return isTrustedContact(addedByContact.attributes);
|
||||||
isMe(conversation.attributes) ||
|
|
||||||
conversation.get('name') ||
|
|
||||||
conversation.get('profileSharing')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue