fix avatar closed group and pubkey for medium mobile groups

pull/1344/head
Audric Ackermann 5 years ago
parent f11cb7744d
commit 8123508b51
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -91,9 +91,10 @@ export class Avatar extends React.PureComponent<Props, State> {
} }
public render() { public render() {
const { avatarPath, size } = this.props; const { avatarPath, size, memberAvatars } = this.props;
const { imageBroken } = this.state; const { imageBroken } = this.state;
const hasImage = avatarPath && !imageBroken; const isClosedGroupAvatar = memberAvatars && memberAvatars.length;
const hasImage = avatarPath && !imageBroken && !isClosedGroupAvatar;
if ( if (
size !== 28 && size !== 28 &&

@ -312,7 +312,7 @@ class ConversationListItem extends React.PureComponent<Props> {
const triggerId = `conversation-item-${phoneNumber}-ctxmenu`; const triggerId = `conversation-item-${phoneNumber}-ctxmenu`;
return ( return (
<div> <div key={triggerId}>
<ContextMenuTrigger id={triggerId}> <ContextMenuTrigger id={triggerId}>
<div <div
role="button" role="button"

@ -27,7 +27,7 @@ export function usingClosedConversationDetails(WrappedComponent: any) {
void this.fetchClosedConversationDetails(); void this.fetchClosedConversationDetails();
} }
public componentDidUpdate() { public componentWillReceiveProps() {
void this.fetchClosedConversationDetails(); void this.fetchClosedConversationDetails();
} }
@ -66,7 +66,7 @@ export function usingClosedConversationDetails(WrappedComponent: any) {
members.push(ourPrimary); members.push(ourPrimary);
} }
// no need to forward more than 2 conversations for rendering the group avatar // no need to forward more than 2 conversations for rendering the group avatar
members.slice(0, 2); members = members.slice(0, 2);
const memberConvos = await Promise.all( const memberConvos = await Promise.all(
members.map(async m => members.map(async m =>
window.ConversationController.getOrCreateAndWait(m.key, 'private') window.ConversationController.getOrCreateAndWait(m.key, 'private')
@ -79,10 +79,9 @@ export function usingClosedConversationDetails(WrappedComponent: any) {
name: m.get('name') || m.get('profileName') || m.id, name: m.get('name') || m.get('profileName') || m.id,
}; };
}); });
this.setState({ memberAvatars });
if (!_.isEqual(memberAvatars, this.state.memberAvatars)) { } else {
this.setState({ memberAvatars }); this.setState({ memberAvatars: undefined });
}
} }
} }
}; };

@ -388,81 +388,83 @@ export async function innerHandleContentMessage(
plaintext: ArrayBuffer plaintext: ArrayBuffer
): Promise<void> { ): Promise<void> {
const { ConversationController } = window; const { ConversationController } = window;
try {
const content = SignalService.Content.decode(new Uint8Array(plaintext)); const content = SignalService.Content.decode(new Uint8Array(plaintext));
const blocked = await isBlocked(envelope.source); const blocked = await isBlocked(envelope.source);
if (blocked) { if (blocked) {
// We want to allow a blocked user message if that's a control message for a known group and the group is not blocked // We want to allow a blocked user message if that's a control message for a known group and the group is not blocked
if (shouldDropBlockedUserMessage(content)) { if (shouldDropBlockedUserMessage(content)) {
window.log.info('Dropping blocked user message'); window.log.info('Dropping blocked user message');
return; return;
} else { } else {
window.log.info('Allowing group-control message only from blocked user'); window.log.info(
'Allowing group-control message only from blocked user'
);
}
} }
} const { FALLBACK_MESSAGE } = SignalService.Envelope.Type;
const { FALLBACK_MESSAGE } = SignalService.Envelope.Type;
await ConversationController.getOrCreateAndWait(envelope.source, 'private'); await ConversationController.getOrCreateAndWait(envelope.source, 'private');
if (content.preKeyBundleMessage) { if (content.preKeyBundleMessage) {
await handleSessionRequestMessage(envelope, content.preKeyBundleMessage); await handleSessionRequestMessage(envelope, content.preKeyBundleMessage);
} else if (envelope.type !== FALLBACK_MESSAGE) { } else if (envelope.type !== FALLBACK_MESSAGE) {
const device = new PubKey(envelope.source); const device = new PubKey(envelope.source);
await SessionProtocol.onSessionEstablished(device); await SessionProtocol.onSessionEstablished(device);
await libsession.getMessageQueue().processPending(device); await libsession.getMessageQueue().processPending(device);
} }
if (content.pairingAuthorisation) { if (content.pairingAuthorisation) {
await handlePairingAuthorisationMessage( await handlePairingAuthorisationMessage(
envelope, envelope,
content.pairingAuthorisation, content.pairingAuthorisation,
content.dataMessage content.dataMessage
); );
return; return;
} }
if (content.syncMessage) { if (content.syncMessage) {
await handleSyncMessage(envelope, content.syncMessage); await handleSyncMessage(envelope, content.syncMessage);
return; return;
} }
if (content.dataMessage) { if (content.dataMessage) {
if ( if (
content.dataMessage.profileKey && content.dataMessage.profileKey &&
content.dataMessage.profileKey.length === 0 content.dataMessage.profileKey.length === 0
) { ) {
content.dataMessage.profileKey = null; content.dataMessage.profileKey = null;
}
await handleDataMessage(envelope, content.dataMessage);
return;
} }
await handleDataMessage(envelope, content.dataMessage); if (content.nullMessage) {
return; await handleNullMessage(envelope);
} return;
if (content.nullMessage) {
await handleNullMessage(envelope);
return;
}
if (content.callMessage) {
await handleCallMessage(envelope);
return;
}
if (content.receiptMessage) {
await handleReceiptMessage(envelope, content.receiptMessage);
return;
}
if (content.typingMessage) {
if (
content.typingMessage.groupId &&
content.typingMessage.groupId.length === 0
) {
content.typingMessage.groupId = null;
} }
await handleTypingMessage(envelope, content.typingMessage); if (content.callMessage) {
return; await handleCallMessage(envelope);
return;
}
if (content.receiptMessage) {
await handleReceiptMessage(envelope, content.receiptMessage);
return;
}
if (content.typingMessage) {
if (
content.typingMessage.groupId &&
content.typingMessage.groupId.length === 0
) {
content.typingMessage.groupId = null;
}
await handleTypingMessage(envelope, content.typingMessage);
return;
}
} catch (e) {
window.log.warn(e);
} }
return;
} }
function onReadReceipt(readAt: any, timestamp: any, reader: any) { function onReadReceipt(readAt: any, timestamp: any, reader: any) {

@ -1,17 +1,30 @@
export class PubKey { export class PubKey {
public static readonly PUBKEY_LEN = 66; public static readonly PUBKEY_LEN = 66;
private static readonly HEX = '[0-9a-fA-F]';
// This is a temporary fix to allow groupPubkeys created from mobile to be handled correctly // This is a temporary fix to allow groupPubkeys created from mobile to be handled correctly
// They have a different regex to match // They have a different regex to match
// FIXME move this to a new class which validates group ids and use it in all places where we have group ids (message sending included) // FIXME move this to a new class which validates group ids and use it in all places where we have group ids (message sending included)
public static readonly MOBILE_GROUP_PUBKEY_LEN = 32; // tslint:disable: member-ordering
public static readonly regexForPubkeys = `((05)?[0-9a-fA-F]{${PubKey.PUBKEY_LEN - public static readonly regexForPubkeys = `((05)?${PubKey.HEX}{64})`;
2}})`; public static readonly PREFIX_GROUP_TEXTSECURE = '__textsecure_group__!';
private static readonly regexForMobileGroupID = `__textsecure_group__![0-9a-fA-F]{${PubKey.MOBILE_GROUP_PUBKEY_LEN}}`;
// prettier-ignore // prettier-ignore
private static readonly regex: RegExp = new RegExp( private static readonly regex: RegExp = new RegExp(
`^${PubKey.regexForPubkeys}|${PubKey.regexForMobileGroupID}$` `^(${PubKey.PREFIX_GROUP_TEXTSECURE})?(05)?(${PubKey.HEX}{64}|${PubKey.HEX}{32})$`
); );
/**
* If you want to update this regex. Be sure that those are matches ;
* __textsecure_group__!05010203040506070809a0b0c0d0e0f0ff010203040506070809a0b0c0d0e0f0ff
* __textsecure_group__!010203040506070809a0b0c0d0e0f0ff010203040506070809a0b0c0d0e0f0ff
* __textsecure_group__!05010203040506070809a0b0c0d0e0f0ff
* __textsecure_group__!010203040506070809a0b0c0d0e0f0ff
* 05010203040506070809a0b0c0d0e0f0ff010203040506070809a0b0c0d0e0f0ff
* 010203040506070809a0b0c0d0e0f0ff010203040506070809a0B0c0d0e0f0FF
* 05010203040506070809a0b0c0d0e0f0ff
* 010203040506070809a0b0c0d0e0f0ff
*/
public readonly key: string; public readonly key: string;
/** /**

Loading…
Cancel
Save