|
|
|
@ -11,6 +11,7 @@ import { getConversationController } from '../session/conversations';
|
|
|
|
|
import { UserUtils } from '../session/utils';
|
|
|
|
|
import { toHex } from '../session/utils/String';
|
|
|
|
|
import { configurationMessageReceived, trigger } from '../shims/events';
|
|
|
|
|
import { BlockedNumberController } from '../util';
|
|
|
|
|
import { removeFromCache } from './cache';
|
|
|
|
|
import { handleNewClosedGroup } from './closedGroups';
|
|
|
|
|
import { updateProfileOneAtATime } from './dataMessage';
|
|
|
|
@ -111,32 +112,41 @@ async function handleGroupsAndContactsFromConfigMessage(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (configMessage.contacts?.length) {
|
|
|
|
|
await Promise.all(
|
|
|
|
|
configMessage.contacts.map(async c => {
|
|
|
|
|
await Promise.all(configMessage.contacts.map(async c => handleContactReceived(c, envelope)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleContactReceived = async (
|
|
|
|
|
contactReceived: SignalService.ConfigurationMessage.IContact,
|
|
|
|
|
envelope: EnvelopePlus
|
|
|
|
|
) => {
|
|
|
|
|
try {
|
|
|
|
|
if (!c.publicKey) {
|
|
|
|
|
if (!contactReceived.publicKey) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const contactConvo = await getConversationController().getOrCreateAndWait(
|
|
|
|
|
toHex(c.publicKey),
|
|
|
|
|
toHex(contactReceived.publicKey),
|
|
|
|
|
ConversationTypeEnum.PRIVATE
|
|
|
|
|
);
|
|
|
|
|
const profile = {
|
|
|
|
|
displayName: c.name,
|
|
|
|
|
profilePictre: c.profilePicture,
|
|
|
|
|
displayName: contactReceived.name,
|
|
|
|
|
profilePictre: contactReceived.profilePicture,
|
|
|
|
|
};
|
|
|
|
|
// updateProfile will do a commit for us
|
|
|
|
|
contactConvo.set('active_at', _.toNumber(envelope.timestamp));
|
|
|
|
|
contactConvo.setIsApproved(Boolean(c.isApproved));
|
|
|
|
|
contactConvo.setIsApproved(Boolean(contactReceived.isApproved));
|
|
|
|
|
|
|
|
|
|
await updateProfileOneAtATime(contactConvo, profile, c.profileKey);
|
|
|
|
|
if (contactReceived.isBlocked === true) {
|
|
|
|
|
await BlockedNumberController.block(contactConvo.id);
|
|
|
|
|
} else {
|
|
|
|
|
await BlockedNumberController.unblock(contactConvo.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await updateProfileOneAtATime(contactConvo, profile, contactReceived.profileKey);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
window?.log?.warn('failed to handle a new closed group from configuration message');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export async function handleConfigurationMessage(
|
|
|
|
|
envelope: EnvelopePlus,
|
|
|
|
|