Deprecate phone number discovery notification
This commit is contained in:
parent
63509b8965
commit
d7b09b9703
21 changed files with 196 additions and 517 deletions
|
@ -1912,14 +1912,7 @@ export class ConversationModel extends window.Backbone
|
|||
};
|
||||
}
|
||||
|
||||
updateE164(
|
||||
e164?: string | null,
|
||||
{
|
||||
disableDiscoveryNotification,
|
||||
}: {
|
||||
disableDiscoveryNotification?: boolean;
|
||||
} = {}
|
||||
): void {
|
||||
updateE164(e164?: string | null): void {
|
||||
const oldValue = this.get('e164');
|
||||
if (e164 === oldValue) {
|
||||
return;
|
||||
|
@ -1927,15 +1920,6 @@ export class ConversationModel extends window.Backbone
|
|||
|
||||
this.set('e164', e164 || undefined);
|
||||
|
||||
// We just discovered a new phone number for this account. If we're not merging
|
||||
// then we'll add a standalone notification here.
|
||||
const haveSentMessage = Boolean(
|
||||
this.get('profileSharing') || this.get('sentMessageCount')
|
||||
);
|
||||
if (!oldValue && e164 && haveSentMessage && !disableDiscoveryNotification) {
|
||||
void this.addPhoneNumberDiscovery(e164);
|
||||
}
|
||||
|
||||
// This user changed their phone number
|
||||
if (oldValue && e164) {
|
||||
void this.addChangeNumberNotification(oldValue, e164);
|
||||
|
@ -3083,43 +3067,6 @@ export class ConversationModel extends window.Backbone
|
|||
});
|
||||
}
|
||||
|
||||
async addPhoneNumberDiscovery(e164: string): Promise<void> {
|
||||
log.info(
|
||||
`addPhoneNumberDiscovery/${this.idForLogging()}: Adding for ${e164}`
|
||||
);
|
||||
|
||||
const timestamp = Date.now();
|
||||
const message: MessageAttributesType = {
|
||||
id: generateGuid(),
|
||||
conversationId: this.id,
|
||||
type: 'phone-number-discovery',
|
||||
sent_at: timestamp,
|
||||
timestamp,
|
||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
||||
received_at_ms: timestamp,
|
||||
phoneNumberDiscovery: {
|
||||
e164,
|
||||
},
|
||||
readStatus: ReadStatus.Read,
|
||||
seenStatus: SeenStatus.Unseen,
|
||||
schemaVersion: Message.VERSION_NEEDED_FOR_DISPLAY,
|
||||
};
|
||||
|
||||
const id = await window.Signal.Data.saveMessage(message, {
|
||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||
forceSave: true,
|
||||
});
|
||||
const model = window.MessageController.register(
|
||||
id,
|
||||
new window.Whisper.Message({
|
||||
...message,
|
||||
id,
|
||||
})
|
||||
);
|
||||
|
||||
this.trigger('newmessage', model);
|
||||
}
|
||||
|
||||
async addConversationMerge(
|
||||
renderInfo: ConversationRenderInfoType
|
||||
): Promise<void> {
|
||||
|
@ -4845,7 +4792,6 @@ export class ConversationModel extends window.Backbone
|
|||
// same before/after string, even if someone is moving from just first name to
|
||||
// first/last name in their profile data.
|
||||
const nameChanged = oldName !== newName;
|
||||
|
||||
if (!isMe(this.attributes) && hadPreviousName && nameChanged) {
|
||||
const change = {
|
||||
type: 'name',
|
||||
|
@ -4902,8 +4848,10 @@ export class ConversationModel extends window.Backbone
|
|||
profileKey: string | undefined,
|
||||
{ viaStorageServiceSync = false } = {}
|
||||
): Promise<boolean> {
|
||||
const oldProfileKey = this.get('profileKey');
|
||||
|
||||
// profileKey is a string so we can compare it directly
|
||||
if (this.get('profileKey') !== profileKey) {
|
||||
if (oldProfileKey !== profileKey) {
|
||||
log.info(
|
||||
`Setting sealedSender to UNKNOWN for conversation ${this.idForLogging()}`
|
||||
);
|
||||
|
|
|
@ -115,7 +115,6 @@ import {
|
|||
isVerifiedChange,
|
||||
processBodyRanges,
|
||||
isConversationMerge,
|
||||
isPhoneNumberDiscovery,
|
||||
} from '../state/selectors/message';
|
||||
import {
|
||||
isInCall,
|
||||
|
@ -174,8 +173,7 @@ import { GiftBadgeStates } from '../components/conversation/Message';
|
|||
import { downloadAttachment } from '../util/downloadAttachment';
|
||||
import type { StickerWithHydratedData } from '../types/Stickers';
|
||||
import { getStringForConversationMerge } from '../util/getStringForConversationMerge';
|
||||
import { getStringForPhoneNumberDiscovery } from '../util/getStringForPhoneNumberDiscovery';
|
||||
import { getTitle, renderNumber } from '../util/getTitle';
|
||||
import { getTitleNoDefault, getNumber } from '../util/getTitle';
|
||||
import dataInterface from '../sql/Client';
|
||||
|
||||
function isSameUuid(
|
||||
|
@ -409,7 +407,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
!isGroupV1Migration(attributes) &&
|
||||
!isGroupV2Change(attributes) &&
|
||||
!isKeyChange(attributes) &&
|
||||
!isPhoneNumberDiscovery(attributes) &&
|
||||
!isProfileChange(attributes) &&
|
||||
!isUniversalTimerNotification(attributes) &&
|
||||
!isUnsupportedMessage(attributes) &&
|
||||
|
@ -499,7 +496,10 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
|
||||
return {
|
||||
text: getStringForConversationMerge({
|
||||
obsoleteConversationTitle: getTitle(
|
||||
obsoleteConversationTitle: getTitleNoDefault(
|
||||
attributes.conversationMerge.renderInfo
|
||||
),
|
||||
obsoleteConversationNumber: getNumber(
|
||||
attributes.conversationMerge.renderInfo
|
||||
),
|
||||
conversationTitle: conversation.getTitle(),
|
||||
|
@ -508,24 +508,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
};
|
||||
}
|
||||
|
||||
if (isPhoneNumberDiscovery(attributes)) {
|
||||
const conversation = this.getConversation();
|
||||
strictAssert(conversation, 'getNotificationData/isPhoneNumberDiscovery');
|
||||
strictAssert(
|
||||
attributes.phoneNumberDiscovery,
|
||||
'getNotificationData/isPhoneNumberDiscovery/phoneNumberDiscovery'
|
||||
);
|
||||
|
||||
return {
|
||||
text: getStringForPhoneNumberDiscovery({
|
||||
phoneNumber: renderNumber(attributes.phoneNumberDiscovery.e164),
|
||||
conversationTitle: conversation.getTitle(),
|
||||
sharedGroup: conversation.get('sharedGroupNames')?.[0],
|
||||
i18n: window.i18n,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
if (isChatSessionRefreshed(attributes)) {
|
||||
return {
|
||||
emoji: '🔁',
|
||||
|
@ -1219,7 +1201,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
const isUniversalTimerNotificationValue =
|
||||
isUniversalTimerNotification(attributes);
|
||||
const isConversationMergeValue = isConversationMerge(attributes);
|
||||
const isPhoneNumberDiscoveryValue = isPhoneNumberDiscovery(attributes);
|
||||
|
||||
const isPayment = messageHasPaymentEvent(attributes);
|
||||
|
||||
|
@ -1251,8 +1232,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
isKeyChangeValue ||
|
||||
isProfileChangeValue ||
|
||||
isUniversalTimerNotificationValue ||
|
||||
isConversationMergeValue ||
|
||||
isPhoneNumberDiscoveryValue;
|
||||
isConversationMergeValue;
|
||||
|
||||
return !hasSomethingToDisplay;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue