fix avatar loading for opengroupv2

This commit is contained in:
Audric Ackermann 2021-05-06 17:56:02 +10:00
parent 15880593df
commit c77b24a2d4
No known key found for this signature in database
GPG key ID: 999F434D76324AD4
5 changed files with 31 additions and 12 deletions

View file

@ -5,6 +5,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:

View file

@ -9,7 +9,7 @@ import { toHex } from '../session/utils/String';
import { configurationMessageReceived, trigger } from '../shims/events';
import { removeFromCache } from './cache';
import { handleNewClosedGroup } from './closedGroups';
import { updateProfile } from './dataMessage';
import { updateProfileOneAtATime } from './dataMessage';
import { EnvelopePlus } from './types';
async function handleOurProfileUpdate(
@ -39,7 +39,7 @@ async function handleOurProfileUpdate(
displayName,
profilePicture,
};
await updateProfile(ourConversation, lokiProfile, profileKey);
await updateProfileOneAtATime(ourConversation, lokiProfile, profileKey);
UserUtils.setLastProfileUpdateTimestamp(_.toNumber(sentAt));
// do not trigger a signin by linking if the display name is empty
if (displayName) {
@ -121,7 +121,7 @@ async function handleGroupsAndContactsFromConfigMessage(
// updateProfile will do a commit for us
contactConvo.set('active_at', _.toNumber(envelope.timestamp));
await updateProfile(contactConvo, profile, c.profileKey);
await updateProfileOneAtATime(contactConvo, profile, c.profileKey);
} catch (e) {
window?.log?.warn('failed to handle a new closed group from configuration message');
}

View file

@ -16,8 +16,24 @@ import { MessageModelType } from '../models/messageType';
import { getMessageBySender, getMessageBySenderAndServerId } from '../../ts/data/data';
import { ConversationModel, ConversationTypeEnum } from '../models/conversation';
import { DeliveryReceiptMessage } from '../session/messages/outgoing/controlMessage/receipt/DeliveryReceiptMessage';
import { allowOnlyOneAtATime } from '../session/utils/Promise';
export async function updateProfile(
export async function updateProfileOneAtATime(
conversation: ConversationModel,
profile: SignalService.DataMessage.ILokiProfile,
profileKey: any
) {
if (!conversation?.id) {
window.log.warn('Cannot update profile with empty convoid');
return;
}
const oneAtaTimeStr = `updateProfileOneAtATime:${conversation.id}`;
return allowOnlyOneAtATime(oneAtaTimeStr, async () => {
return updateProfile(conversation, profile, profileKey);
});
}
async function updateProfile(
conversation: ConversationModel,
profile: SignalService.DataMessage.ILokiProfile,
profileKey: any
@ -285,7 +301,7 @@ export async function handleDataMessage(
// Check if we need to update any profile names
if (!isMe && senderConversation && message.profile) {
await updateProfile(senderConversation, message.profile, message.profileKey);
await updateProfileOneAtATime(senderConversation, message.profile, message.profileKey);
}
if (isMessageEmpty(message)) {
window.log.warn(`Message ${getEnvelopeId(envelope)} ignored; it was empty`);

View file

@ -11,7 +11,7 @@ import { MessageModel } from '../models/message';
import { MessageController } from '../session/messages';
import { getMessageById, getMessagesBySentAt } from '../../ts/data/data';
import { actions as conversationActions } from '../state/ducks/conversations';
import { updateProfile } from './dataMessage';
import { updateProfileOneAtATime } from './dataMessage';
import Long from 'long';
async function handleGroups(
@ -299,7 +299,6 @@ async function handleRegularMessage(
const { upgradeMessageSchema } = window.Signal.Migrations;
const type = message.get('type');
await copyFromQuotedMessage(message, initialMessage.quote);
// `upgradeMessageSchema` only seems to add `schemaVersion: 10` to the message
@ -371,14 +370,15 @@ async function handleRegularMessage(
source,
ConversationTypeEnum.PRIVATE
);
// Check if we need to update any profile names
// the only profile we don't update with what is coming here is ours,
// as our profile is shared accross our devices with a ConfigurationMessage
if (type === 'incoming' && dataMessage.profile) {
await updateProfile(
if (type === 'incoming' && dataMessage.profile && dataMessage.profile && dataMessage.profileKey) {
void updateProfileOneAtATime(
sendingDeviceConversation,
dataMessage.profile,
dataMessage.profile?.profileKey
dataMessage.profileKey
);
}

View file

@ -19,7 +19,7 @@ import {
handleMessageEvent,
isMessageDuplicate,
MessageCreationData,
updateProfile,
updateProfileOneAtATime,
} from './dataMessage';
import { getEnvelopeId } from './common';
@ -283,7 +283,7 @@ export async function handlePublicMessage(messageData: any) {
source,
ConversationTypeEnum.PRIVATE
);
await updateProfile(conversation, profile, profileKey);
await updateProfileOneAtATime(conversation, profile, profileKey);
}
const isPublicVisibleMessage = group && group.id && !!group.id.match(openGroupPrefixRegex);