Force configuration message on avatar or display name update

pull/1515/head
Audric Ackermann 4 years ago
parent 92901d9462
commit e0c2cf8e9a
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -615,7 +615,10 @@
displayName: newName,
avatar: newAvatarPath,
});
conversation.commit();
await conversation.commit();
await window.libsession.Utils.SyncUtils.forceSyncConfigurationNowIfNeeded(
true
);
} catch (error) {
window.log.error(
'showEditProfileDialog Error ensuring that image is properly sized:',
@ -627,9 +630,12 @@
conversation.setLokiProfile({
displayName: newName,
});
await conversation.commit();
await window.libsession.Utils.SyncUtils.forceSyncConfigurationNowIfNeeded(
true
);
}
conversation.commit();
// inform all your registered public servers
// could put load on all the servers
// if they just keep changing their names without sending messages

@ -83,17 +83,13 @@ export class ConfigurationMessage extends ContentMessage {
private mapClosedGroupsObjectToProto(
closedGroups: Array<ConfigurationMessageClosedGroup>
): Array<SignalService.ConfigurationMessage.ClosedGroup> {
return (closedGroups || []).map(m =>
new ConfigurationMessageClosedGroup(m).toProto()
);
return (closedGroups || []).map(m => m.toProto());
}
private mapContactsObjectToProto(
contacts: Array<ConfigurationMessageContact>
): Array<SignalService.ConfigurationMessage.Contact> {
return (contacts || []).map(m =>
new ConfigurationMessageContact(m).toProto()
);
return (contacts || []).map(m => m.toProto());
}
}

@ -116,14 +116,17 @@ export const getCurrentConfigurationMessage = async (
// Filter contacts
const contactsModels = convos.filter(
c => !!c.get('active_at') && c.isPrivate() && !c.isBlocked()
c =>
!!c.get('active_at') &&
c.getLokiProfile()?.displayName &&
c.isPrivate() &&
!c.isBlocked()
);
const contacts = contactsModels.map(c => {
const groupPubKey = c.get('id');
return new ConfigurationMessageContact({
publicKey: groupPubKey,
displayName: c.get('name'),
publicKey: c.id,
displayName: c.getLokiProfile()?.displayName,
profilePictureURL: c.get('avatarPointer'),
profileKey: c.get('profileKey'),
});

@ -227,8 +227,16 @@ describe('ConfigurationMessage', () => {
expect(() => new ConfigurationMessageContact(params2)).to.throw();
});
it('throw if the contact has an empty disploy name', () => {
// a display name cannot be empty. It should be undefined rather than empty
it('throw if the contact has an empty display name', () => {
// a display name cannot be empty nor undefined
const params = {
publicKey: TestUtils.generateFakePubKey().key,
displayName: undefined as any,
};
expect(() => new ConfigurationMessageContact(params2)).to.throw();
const params2 = {
publicKey: TestUtils.generateFakePubKey().key,
displayName: '',

Loading…
Cancel
Save