Use UUIDs in group database schema
This commit is contained in:
parent
74fde10ff5
commit
63fcdbe787
79 changed files with 4530 additions and 3664 deletions
|
@ -4,13 +4,14 @@
|
|||
import type { FullJSXType } from './components/Intl';
|
||||
import type { LocalizerType } from './types/Util';
|
||||
import type { ReplacementValuesType } from './types/I18N';
|
||||
import type { UUIDStringType } from './types/UUID';
|
||||
import { missingCaseError } from './util/missingCaseError';
|
||||
|
||||
import type { GroupV2ChangeDetailType, GroupV2ChangeType } from './groups';
|
||||
import { SignalService as Proto } from './protobuf';
|
||||
import * as log from './logging/log';
|
||||
|
||||
export type SmartContactRendererType = (conversationId: string) => FullJSXType;
|
||||
export type SmartContactRendererType = (uuid: UUIDStringType) => FullJSXType;
|
||||
export type StringRendererType = (
|
||||
id: string,
|
||||
i18n: LocalizerType,
|
||||
|
@ -18,9 +19,9 @@ export type StringRendererType = (
|
|||
) => FullJSXType;
|
||||
|
||||
export type RenderOptionsType = {
|
||||
from?: string;
|
||||
from?: UUIDStringType;
|
||||
i18n: LocalizerType;
|
||||
ourConversationId: string;
|
||||
ourUuid: UUIDStringType;
|
||||
renderContact: SmartContactRendererType;
|
||||
renderString: StringRendererType;
|
||||
};
|
||||
|
@ -46,14 +47,8 @@ export function renderChangeDetail(
|
|||
detail: GroupV2ChangeDetailType,
|
||||
options: RenderOptionsType
|
||||
): FullJSXType {
|
||||
const {
|
||||
from,
|
||||
i18n,
|
||||
ourConversationId,
|
||||
renderContact,
|
||||
renderString,
|
||||
} = options;
|
||||
const fromYou = Boolean(from && from === ourConversationId);
|
||||
const { from, i18n, ourUuid, renderContact, renderString } = options;
|
||||
const fromYou = Boolean(from && from === ourUuid);
|
||||
|
||||
if (detail.type === 'create') {
|
||||
if (fromYou) {
|
||||
|
@ -214,8 +209,8 @@ export function renderChangeDetail(
|
|||
return '';
|
||||
}
|
||||
if (detail.type === 'member-add') {
|
||||
const { conversationId } = detail;
|
||||
const weAreJoiner = conversationId === ourConversationId;
|
||||
const { uuid } = detail;
|
||||
const weAreJoiner = uuid === ourUuid;
|
||||
|
||||
if (weAreJoiner) {
|
||||
if (fromYou) {
|
||||
|
@ -230,25 +225,25 @@ export function renderChangeDetail(
|
|||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-add--other--you', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-add--other--other', i18n, {
|
||||
adderName: renderContact(from),
|
||||
addeeName: renderContact(conversationId),
|
||||
addeeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-add--other--unknown', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (detail.type === 'member-add-from-invite') {
|
||||
const { conversationId, inviter } = detail;
|
||||
const weAreJoiner = conversationId === ourConversationId;
|
||||
const weAreInviter = Boolean(inviter && inviter === ourConversationId);
|
||||
const { uuid, inviter } = detail;
|
||||
const weAreJoiner = uuid === ourUuid;
|
||||
const weAreInviter = Boolean(inviter && inviter === ourUuid);
|
||||
|
||||
if (!from || from !== conversationId) {
|
||||
if (!from || from !== uuid) {
|
||||
if (weAreJoiner) {
|
||||
// They can't be the same, no fromYou check here
|
||||
if (from) {
|
||||
|
@ -261,17 +256,17 @@ export function renderChangeDetail(
|
|||
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-add--invited--you', i18n, {
|
||||
inviteeName: renderContact(conversationId),
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-add--invited--other', i18n, {
|
||||
memberName: renderContact(from),
|
||||
inviteeName: renderContact(conversationId),
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-add--invited--unknown', i18n, {
|
||||
inviteeName: renderContact(conversationId),
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -288,12 +283,12 @@ export function renderChangeDetail(
|
|||
}
|
||||
if (weAreInviter) {
|
||||
return renderString('GroupV2--member-add--from-invite--from-you', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (inviter) {
|
||||
return renderString('GroupV2--member-add--from-invite--other', i18n, {
|
||||
inviteeName: renderContact(conversationId),
|
||||
inviteeName: renderContact(uuid),
|
||||
inviterName: renderContact(inviter),
|
||||
});
|
||||
}
|
||||
|
@ -301,17 +296,17 @@ export function renderChangeDetail(
|
|||
'GroupV2--member-add--from-invite--other-no-from',
|
||||
i18n,
|
||||
{
|
||||
inviteeName: renderContact(conversationId),
|
||||
inviteeName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
if (detail.type === 'member-add-from-link') {
|
||||
const { conversationId } = detail;
|
||||
const { uuid } = detail;
|
||||
|
||||
if (fromYou && conversationId === ourConversationId) {
|
||||
if (fromYou && uuid === ourUuid) {
|
||||
return renderString('GroupV2--member-add-from-link--you--you', i18n);
|
||||
}
|
||||
if (from && conversationId === from) {
|
||||
if (from && uuid === from) {
|
||||
return renderString('GroupV2--member-add-from-link--other', i18n, [
|
||||
renderContact(from),
|
||||
]);
|
||||
|
@ -321,12 +316,12 @@ export function renderChangeDetail(
|
|||
// from group change events, which always have a sender.
|
||||
log.warn('member-add-from-link change type; we have no from!');
|
||||
return renderString('GroupV2--member-add--other--unknown', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (detail.type === 'member-add-from-admin-approval') {
|
||||
const { conversationId } = detail;
|
||||
const weAreJoiner = conversationId === ourConversationId;
|
||||
const { uuid } = detail;
|
||||
const weAreJoiner = uuid === ourUuid;
|
||||
|
||||
if (weAreJoiner) {
|
||||
if (from) {
|
||||
|
@ -352,7 +347,7 @@ export function renderChangeDetail(
|
|||
return renderString(
|
||||
'GroupV2--member-add-from-admin-approval--other--you',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
|
@ -361,7 +356,7 @@ export function renderChangeDetail(
|
|||
i18n,
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(conversationId),
|
||||
joinerName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -372,12 +367,12 @@ export function renderChangeDetail(
|
|||
return renderString(
|
||||
'GroupV2--member-add-from-admin-approval--other--unknown',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (detail.type === 'member-remove') {
|
||||
const { conversationId } = detail;
|
||||
const weAreLeaver = conversationId === ourConversationId;
|
||||
const { uuid } = detail;
|
||||
const weAreLeaver = uuid === ourUuid;
|
||||
|
||||
if (weAreLeaver) {
|
||||
if (fromYou) {
|
||||
|
@ -393,10 +388,10 @@ export function renderChangeDetail(
|
|||
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-remove--other--you', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (from && from === conversationId) {
|
||||
if (from && from === uuid) {
|
||||
return renderString('GroupV2--member-remove--other--self', i18n, [
|
||||
renderContact(from),
|
||||
]);
|
||||
|
@ -404,16 +399,16 @@ export function renderChangeDetail(
|
|||
if (from) {
|
||||
return renderString('GroupV2--member-remove--other--other', i18n, {
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(conversationId),
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-remove--other--unknown', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (detail.type === 'member-privilege') {
|
||||
const { conversationId, newPrivilege } = detail;
|
||||
const weAreMember = conversationId === ourConversationId;
|
||||
const { uuid, newPrivilege } = detail;
|
||||
const weAreMember = uuid === ourUuid;
|
||||
|
||||
if (newPrivilege === RoleEnum.ADMINISTRATOR) {
|
||||
if (weAreMember) {
|
||||
|
@ -435,7 +430,7 @@ export function renderChangeDetail(
|
|||
return renderString(
|
||||
'GroupV2--member-privilege--promote--other--you',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
|
@ -444,14 +439,14 @@ export function renderChangeDetail(
|
|||
i18n,
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(conversationId),
|
||||
memberName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--promote--other--unknown',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (newPrivilege === RoleEnum.DEFAULT) {
|
||||
|
@ -473,7 +468,7 @@ export function renderChangeDetail(
|
|||
return renderString(
|
||||
'GroupV2--member-privilege--demote--other--you',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
|
@ -482,14 +477,14 @@ export function renderChangeDetail(
|
|||
i18n,
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(conversationId),
|
||||
memberName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--demote--other--unknown',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
log.warn(
|
||||
|
@ -498,8 +493,8 @@ export function renderChangeDetail(
|
|||
return '';
|
||||
}
|
||||
if (detail.type === 'pending-add-one') {
|
||||
const { conversationId } = detail;
|
||||
const weAreInvited = conversationId === ourConversationId;
|
||||
const { uuid } = detail;
|
||||
const weAreInvited = uuid === ourUuid;
|
||||
if (weAreInvited) {
|
||||
if (from) {
|
||||
return renderString('GroupV2--pending-add--one--you--other', i18n, [
|
||||
|
@ -510,7 +505,7 @@ export function renderChangeDetail(
|
|||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--pending-add--one--other--you', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (from) {
|
||||
|
@ -539,23 +534,23 @@ export function renderChangeDetail(
|
|||
]);
|
||||
}
|
||||
if (detail.type === 'pending-remove-one') {
|
||||
const { inviter, conversationId } = detail;
|
||||
const weAreInviter = Boolean(inviter && inviter === ourConversationId);
|
||||
const weAreInvited = conversationId === ourConversationId;
|
||||
const sentByInvited = Boolean(from && from === conversationId);
|
||||
const { inviter, uuid } = detail;
|
||||
const weAreInviter = Boolean(inviter && inviter === ourUuid);
|
||||
const weAreInvited = uuid === ourUuid;
|
||||
const sentByInvited = Boolean(from && from === uuid);
|
||||
const sentByInviter = Boolean(from && inviter && from === inviter);
|
||||
|
||||
if (weAreInviter) {
|
||||
if (sentByInvited) {
|
||||
return renderString('GroupV2--pending-remove--decline--you', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--one--you',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
|
@ -564,14 +559,14 @@ export function renderChangeDetail(
|
|||
i18n,
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
inviteeName: renderContact(conversationId),
|
||||
inviteeName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--one--unknown',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (sentByInvited) {
|
||||
|
@ -635,7 +630,7 @@ export function renderChangeDetail(
|
|||
}
|
||||
if (detail.type === 'pending-remove-many') {
|
||||
const { count, inviter } = detail;
|
||||
const weAreInviter = Boolean(inviter && inviter === ourConversationId);
|
||||
const weAreInviter = Boolean(inviter && inviter === ourUuid);
|
||||
|
||||
if (weAreInviter) {
|
||||
if (fromYou) {
|
||||
|
@ -714,19 +709,19 @@ export function renderChangeDetail(
|
|||
);
|
||||
}
|
||||
if (detail.type === 'admin-approval-add-one') {
|
||||
const { conversationId } = detail;
|
||||
const weAreJoiner = conversationId === ourConversationId;
|
||||
const { uuid } = detail;
|
||||
const weAreJoiner = uuid === ourUuid;
|
||||
|
||||
if (weAreJoiner) {
|
||||
return renderString('GroupV2--admin-approval-add-one--you', i18n);
|
||||
}
|
||||
return renderString('GroupV2--admin-approval-add-one--other', i18n, [
|
||||
renderContact(conversationId),
|
||||
renderContact(uuid),
|
||||
]);
|
||||
}
|
||||
if (detail.type === 'admin-approval-remove-one') {
|
||||
const { conversationId } = detail;
|
||||
const weAreJoiner = conversationId === ourConversationId;
|
||||
const { uuid } = detail;
|
||||
const weAreJoiner = uuid === ourUuid;
|
||||
|
||||
if (weAreJoiner) {
|
||||
if (fromYou) {
|
||||
|
@ -745,14 +740,14 @@ export function renderChangeDetail(
|
|||
return renderString(
|
||||
'GroupV2--admin-approval-remove-one--other--you',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (from && from === conversationId) {
|
||||
if (from && from === uuid) {
|
||||
return renderString(
|
||||
'GroupV2--admin-approval-remove-one--other--own',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
|
@ -761,7 +756,7 @@ export function renderChangeDetail(
|
|||
i18n,
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(conversationId),
|
||||
joinerName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -771,7 +766,7 @@ export function renderChangeDetail(
|
|||
return renderString(
|
||||
'GroupV2--admin-approval-remove-one--other--own',
|
||||
i18n,
|
||||
[renderContact(conversationId)]
|
||||
[renderContact(uuid)]
|
||||
);
|
||||
}
|
||||
if (detail.type === 'group-link-add') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue