Merge pull request #2192 from Bilb/fix-closed-group-no-join-config

join closed groups from config only on the first config message
pull/2193/head
Audric Ackermann 3 years ago committed by GitHub
commit a8de5a1679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -442,7 +442,6 @@ function openReleaseNotes() {
); );
} }
function openSupportPage() { function openSupportPage() {
shell.openExternal('https://docs.oxen.io/products-built-on-oxen/session'); shell.openExternal('https://docs.oxen.io/products-built-on-oxen/session');
} }

@ -1206,6 +1206,7 @@ input {
.session-member-item { .session-member-item {
cursor: pointer; cursor: pointer;
flex-shrink: 0;
font-family: $session-font-default; font-family: $session-font-default;
padding: 0px $session-margin-sm; padding: 0px $session-margin-sm;
height: 50px; height: 50px;

@ -62,6 +62,7 @@ export async function signUp(signUpDetails: {
await createOrUpdateItem({ await createOrUpdateItem({
id: 'hasSyncedInitialConfigurationItem', id: 'hasSyncedInitialConfigurationItem',
value: true, value: true,
timestamp: Date.now(),
}); });
UserUtils.setSignWithRecoveryPhrase(false); UserUtils.setSignWithRecoveryPhrase(false);
trigger('openInbox'); trigger('openInbox');

@ -114,7 +114,7 @@ export async function handleClosedGroupControlMessage(
if ( if (
!getConversationController() !getConversationController()
.get(envelope.senderIdentity) .get(envelope.senderIdentity)
.isApproved() ?.isApproved()
) { ) {
window?.log?.info( window?.log?.info(
'Received new closed group message from an unapproved sender -- dropping message.' 'Received new closed group message from an unapproved sender -- dropping message.'

@ -55,11 +55,11 @@ async function handleGroupsAndContactsFromConfigMessage(
envelope: EnvelopePlus, envelope: EnvelopePlus,
configMessage: SignalService.ConfigurationMessage configMessage: SignalService.ConfigurationMessage
) { ) {
const envelopeTimestamp = _.toNumber(envelope.timestamp);
const lastConfigUpdate = await getItemById(hasSyncedInitialConfigurationItem); const lastConfigUpdate = await getItemById(hasSyncedInitialConfigurationItem);
const lastConfigTimestamp = lastConfigUpdate?.timestamp; const lastConfigTimestamp = lastConfigUpdate?.timestamp;
const isNewerConfig = const isNewerConfig =
!lastConfigTimestamp || !lastConfigTimestamp || (lastConfigTimestamp && lastConfigTimestamp < envelopeTimestamp);
(lastConfigTimestamp && lastConfigTimestamp < _.toNumber(envelope.timestamp));
if (!isNewerConfig) { if (!isNewerConfig) {
window?.log?.info('Received outdated configuration message... Dropping message.'); window?.log?.info('Received outdated configuration message... Dropping message.');
@ -69,32 +69,14 @@ async function handleGroupsAndContactsFromConfigMessage(
await createOrUpdateItem({ await createOrUpdateItem({
id: 'hasSyncedInitialConfigurationItem', id: 'hasSyncedInitialConfigurationItem',
value: true, value: true,
timestamp: _.toNumber(envelope.timestamp), timestamp: envelopeTimestamp,
}); });
const numberClosedGroup = configMessage.closedGroups?.length || 0; // we only want to apply changes to closed groups if we never got them
// new opengroups get added when we get a new closed group message from someone, or a sync'ed message from outself creating the group
window?.log?.info( if (!lastConfigTimestamp) {
`Received ${numberClosedGroup} closed group on configuration. Creating them... ` await handleClosedGroupsFromConfig(configMessage.closedGroups, envelope);
); }
await Promise.all(
configMessage.closedGroups.map(async c => {
const groupUpdate = new SignalService.DataMessage.ClosedGroupControlMessage({
type: SignalService.DataMessage.ClosedGroupControlMessage.Type.NEW,
encryptionKeyPair: c.encryptionKeyPair,
name: c.name,
admins: c.admins,
members: c.members,
publicKey: c.publicKey,
});
try {
await handleNewClosedGroup(envelope, groupUpdate);
} catch (e) {
window?.log?.warn('failed to handle a new closed group from configuration message');
}
})
);
handleOpenGroupsFromConfig(configMessage.openGroups); handleOpenGroupsFromConfig(configMessage.openGroups);
@ -105,7 +87,6 @@ async function handleGroupsAndContactsFromConfigMessage(
/** /**
* Trigger a join for all open groups we are not already in. * Trigger a join for all open groups we are not already in.
* Currently, if you left an open group but kept the conversation, you won't rejoin it here.
* @param openGroups string array of open group urls * @param openGroups string array of open group urls
*/ */
const handleOpenGroupsFromConfig = (openGroups: Array<string>) => { const handleOpenGroupsFromConfig = (openGroups: Array<string>) => {
@ -126,6 +107,40 @@ const handleOpenGroupsFromConfig = (openGroups: Array<string>) => {
} }
}; };
/**
* Trigger a join for all closed groups which doesn't exist yet
* @param openGroups string array of open group urls
*/
const handleClosedGroupsFromConfig = async (
closedGroups: Array<SignalService.ConfigurationMessage.IClosedGroup>,
envelope: EnvelopePlus
) => {
const numberClosedGroup = closedGroups?.length || 0;
window?.log?.info(
`Received ${numberClosedGroup} closed group on configuration. Creating them... `
);
await Promise.all(
closedGroups.map(async c => {
const groupUpdate = new SignalService.DataMessage.ClosedGroupControlMessage({
type: SignalService.DataMessage.ClosedGroupControlMessage.Type.NEW,
encryptionKeyPair: c.encryptionKeyPair,
name: c.name,
admins: c.admins,
members: c.members,
publicKey: c.publicKey,
});
try {
// TODO we should not drop the envelope from cache as long as we are still handling a new closed group from that same envelope
// check the removeFromCache inside handleNewClosedGroup()
await handleNewClosedGroup(envelope, groupUpdate);
} catch (e) {
window?.log?.warn('failed to handle a new closed group from configuration message');
}
})
);
};
/** /**
* Handles adding of a contact and setting approval/block status * Handles adding of a contact and setting approval/block status
* @param contactReceived Contact to sync * @param contactReceived Contact to sync

@ -170,11 +170,10 @@ const lightColorAccentButton = black;
const lightColorText = black; const lightColorText = black;
const lightColorTextOpposite = white; const lightColorTextOpposite = white;
const lightColorTextSubtle = `${black}99`; const lightColorTextSubtle = `${black}99`;
const lightColorTextAccent = '#00c769'; const lightColorTextAccent = accentLightTheme;
const lightColorSessionShadow = `0 0 4px 0 ${black}5E`; const lightColorSessionShadow = `0 0 4px 0 ${black}5E`;
const lightColorComposeViewBg = '#efefef'; const lightColorComposeViewBg = '#efefef';
const lightColorSentMessageBg = 'hsl(152, 100%, 40%)'; const lightColorSentMessageBg = accentLightTheme;
const lightColorSentMessageText = white;
const lightColorClickableHovered = '#dfdfdf'; const lightColorClickableHovered = '#dfdfdf';
const lightColorSessionBorderColor = borderLightThemeColor; const lightColorSessionBorderColor = borderLightThemeColor;
const lightColorSessionBorder = `1px solid ${lightColorSessionBorderColor}`; const lightColorSessionBorder = `1px solid ${lightColorSessionBorderColor}`;
@ -232,10 +231,7 @@ export const switchHtmlToLightTheme = () => {
'--color-sent-message-background', '--color-sent-message-background',
lightColorSentMessageBg lightColorSentMessageBg
); );
document.documentElement.style.setProperty( document.documentElement.style.setProperty('--color-sent-message-text', darkColorSentMessageText);
'--color-sent-message-text',
lightColorSentMessageText
);
document.documentElement.style.setProperty( document.documentElement.style.setProperty(
'--color-clickable-hovered', '--color-clickable-hovered',
lightColorClickableHovered lightColorClickableHovered
@ -364,7 +360,7 @@ export const SessionGlobalStyles = createGlobalStyle`
--color-session-shadow: ${lightColorSessionShadow}; --color-session-shadow: ${lightColorSessionShadow};
--color-compose-view-button-background: ${lightColorComposeViewBg}; --color-compose-view-button-background: ${lightColorComposeViewBg};
--color-sent-message-background: ${lightColorSentMessageBg}; --color-sent-message-background: ${lightColorSentMessageBg};
--color-sent-message-text: ${lightColorSentMessageText}; --color-sent-message-text: ${darkColorSentMessageText};
--color-clickable-hovered: ${lightColorClickableHovered}; --color-clickable-hovered: ${lightColorClickableHovered};
--color-session-border: ${lightColorSessionBorderColor}; --color-session-border: ${lightColorSessionBorderColor};
--color-recovery-phrase-banner-background: ${lightColorRecoveryPhraseBannerBg}; --color-recovery-phrase-banner-background: ${lightColorRecoveryPhraseBannerBg};

@ -7,9 +7,12 @@ export function getInitials(name?: string): string | undefined {
return name[2]; return name[2];
} }
const initials = name.split(' ').slice(0, 2).map(n => { const initials = name
return n[0]; .split(' ')
}) .slice(0, 2)
.map(n => {
return n[0];
});
return initials.join(''); return initials.join('');
} }

Loading…
Cancel
Save