mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
fix profileKey share in config message for base64 profileKey
This commit is contained in:
parent
63cad6b05b
commit
506a0b2927
1 changed files with 10 additions and 2 deletions
|
@ -27,6 +27,7 @@ import { ExpirationTimerUpdateMessage } from '../messages/outgoing/controlMessag
|
|||
import { getV2OpenGroupRoom } from '../../data/opengroups';
|
||||
import { getCompleteUrlFromRoom } from '../../opengroup/utils/OpenGroupUtils';
|
||||
import { DURATION } from '../constants';
|
||||
import { PubKey } from '../types';
|
||||
|
||||
const ITEM_ID_LAST_SYNC_TIMESTAMP = 'lastSyncedTimestamp';
|
||||
|
||||
|
@ -161,12 +162,19 @@ const getValidContacts = (convos: Array<ConversationModel>) => {
|
|||
const contacts = contactsModels.map(c => {
|
||||
try {
|
||||
const profileKey = c.get('profileKey');
|
||||
let profileKeyForContact;
|
||||
let profileKeyForContact = null;
|
||||
if (typeof profileKey === 'string') {
|
||||
// this will throw if the profileKey is not in hex.
|
||||
try {
|
||||
// for some reason, at some point, the saved profileKey is a string in base64 format
|
||||
// this hack is here to update existing conversations with a non-hex profileKey to a hex format and save them
|
||||
|
||||
if (!/^[0-9a-fA-F]+$/.test(profileKey)) {
|
||||
throw new Error('Not Hex');
|
||||
}
|
||||
profileKeyForContact = fromHexToArray(profileKey);
|
||||
} catch (e) {
|
||||
// if not hex, try to decode it as base64
|
||||
profileKeyForContact = fromBase64ToArray(profileKey);
|
||||
// if the line above does not fail, update the stored profileKey for this convo
|
||||
void c.setProfileKey(profileKeyForContact);
|
||||
|
@ -183,7 +191,7 @@ const getValidContacts = (convos: Array<ConversationModel>) => {
|
|||
publicKey: c.id,
|
||||
displayName: c.getLokiProfile()?.displayName,
|
||||
profilePictureURL: c.get('avatarPointer'),
|
||||
profileKey: profileKeyForContact,
|
||||
profileKey: !profileKeyForContact?.length ? undefined : profileKeyForContact,
|
||||
});
|
||||
} catch (e) {
|
||||
window?.log.warn('getValidContacts', e);
|
||||
|
|
Loading…
Reference in a new issue