Clean up conversations with UUID as E164
This commit is contained in:
parent
a22dcc986f
commit
8951665554
4 changed files with 23 additions and 11 deletions
|
@ -13,6 +13,7 @@ import { SendOptionsType, CallbackResultType } from './textsecure/SendMessage';
|
|||
import { ConversationModel } from './models/conversations';
|
||||
import { maybeDeriveGroupV2Id } from './groups';
|
||||
import { assert } from './util/assert';
|
||||
import { isValidGuid } from './util/isValidGuid';
|
||||
import { map, reduce } from './util/iterables';
|
||||
import { isGroupV1, isGroupV2 } from './util/whatTypeOfConversation';
|
||||
import { deprecated } from './util/deprecated';
|
||||
|
@ -843,6 +844,18 @@ export class ConversationController {
|
|||
});
|
||||
updateConversation(conversation.attributes);
|
||||
}
|
||||
|
||||
// Clean up the conversations that have UUID as their e164.
|
||||
const e164 = conversation.get('e164');
|
||||
const uuid = conversation.get('uuid');
|
||||
if (isValidGuid(e164) && uuid) {
|
||||
conversation.set({ e164: undefined });
|
||||
updateConversation(conversation.attributes);
|
||||
|
||||
window.log.info(
|
||||
`Cleaning up conversation(${uuid}) with invalid e164`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
'ConversationController.load/map: Failed to prepare a conversation',
|
||||
|
|
|
@ -619,14 +619,14 @@ export const getConversationSelector = createSelector(
|
|||
return selector(undefined);
|
||||
}
|
||||
|
||||
const onE164 = getOwn(byE164, id);
|
||||
if (onE164) {
|
||||
return selector(onE164);
|
||||
}
|
||||
const onUuid = getOwn(byUuid, id.toLowerCase ? id.toLowerCase() : id);
|
||||
if (onUuid) {
|
||||
return selector(onUuid);
|
||||
}
|
||||
const onE164 = getOwn(byE164, id);
|
||||
if (onE164) {
|
||||
return selector(onE164);
|
||||
}
|
||||
const onGroupId = getOwn(byGroupId, id);
|
||||
if (onGroupId) {
|
||||
return selector(onGroupId);
|
||||
|
|
|
@ -102,7 +102,7 @@ describe('both/state/selectors/conversations', () => {
|
|||
assert.deepEqual(actual, getPlaceholderContact());
|
||||
});
|
||||
|
||||
it('returns conversation by e164 first', () => {
|
||||
it('returns conversation by uuid first', () => {
|
||||
const id = 'id';
|
||||
|
||||
const conversation = makeConversation(id);
|
||||
|
@ -116,10 +116,10 @@ describe('both/state/selectors/conversations', () => {
|
|||
[id]: wrongConversation,
|
||||
},
|
||||
conversationsByE164: {
|
||||
[id]: conversation,
|
||||
[id]: wrongConversation,
|
||||
},
|
||||
conversationsByUuid: {
|
||||
[id]: wrongConversation,
|
||||
[id]: conversation,
|
||||
},
|
||||
conversationsByGroupId: {
|
||||
[id]: wrongConversation,
|
||||
|
@ -133,7 +133,7 @@ describe('both/state/selectors/conversations', () => {
|
|||
|
||||
assert.strictEqual(actual, conversation);
|
||||
});
|
||||
it('returns conversation by uuid', () => {
|
||||
it('returns conversation by e164', () => {
|
||||
const id = 'id';
|
||||
|
||||
const conversation = makeConversation(id);
|
||||
|
@ -146,7 +146,7 @@ describe('both/state/selectors/conversations', () => {
|
|||
conversationLookup: {
|
||||
[id]: wrongConversation,
|
||||
},
|
||||
conversationsByUuid: {
|
||||
conversationsByE164: {
|
||||
[id]: conversation,
|
||||
},
|
||||
conversationsByGroupId: {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
import { ConversationType } from '../state/ducks/conversations';
|
||||
import { format, isValidNumber } from '../types/PhoneNumber';
|
||||
import { normalizeUuid } from './normalizeUuid';
|
||||
|
||||
type FormattedContact = Partial<ConversationType> &
|
||||
Pick<
|
||||
|
@ -32,7 +31,7 @@ export function findAndFormatContact(identifier?: string): FormattedContact {
|
|||
}
|
||||
|
||||
const contactModel = window.ConversationController.get(
|
||||
normalizeUuid(identifier, 'findAndFormatContact')
|
||||
identifier.toLowerCase()
|
||||
);
|
||||
if (contactModel) {
|
||||
return contactModel.format();
|
||||
|
|
Loading…
Reference in a new issue