Make valid-i18n-keys rule strict and fix most exceptions
This commit is contained in:
parent
18a6da310f
commit
11cfcb4e32
36 changed files with 796 additions and 687 deletions
|
@ -67,7 +67,18 @@ export function renderChangeDetail<T>(
|
|||
detail: GroupV2ChangeDetailType,
|
||||
options: RenderOptionsType<T>
|
||||
): T | string | ReadonlyArray<T | string> {
|
||||
const { from, i18n, ourACI, ourPNI, renderContact, renderString } = options;
|
||||
const {
|
||||
from,
|
||||
i18n: localizer,
|
||||
ourACI,
|
||||
ourPNI,
|
||||
renderContact,
|
||||
renderString,
|
||||
} = options;
|
||||
|
||||
function i18n(id: string, components?: ReplacementValuesType<T | string>) {
|
||||
return renderString(id, localizer, components);
|
||||
}
|
||||
|
||||
const isOurUuid = (uuid?: UUIDStringType): boolean => {
|
||||
if (!uuid) {
|
||||
|
@ -79,88 +90,88 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (detail.type === 'create') {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--create--you', i18n);
|
||||
return i18n('GroupV2--create--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--create--other', i18n, {
|
||||
return i18n('GroupV2--create--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--create--unknown', i18n);
|
||||
return i18n('GroupV2--create--unknown');
|
||||
}
|
||||
if (detail.type === 'title') {
|
||||
const { newTitle } = detail;
|
||||
|
||||
if (newTitle) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--title--change--you', i18n, { newTitle });
|
||||
return i18n('GroupV2--title--change--you', { newTitle });
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--title--change--other', i18n, {
|
||||
return i18n('GroupV2--title--change--other', {
|
||||
memberName: renderContact(from),
|
||||
newTitle,
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--title--change--unknown', i18n, {
|
||||
return i18n('GroupV2--title--change--unknown', {
|
||||
newTitle,
|
||||
});
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--title--remove--you', i18n);
|
||||
return i18n('GroupV2--title--remove--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--title--remove--other', i18n, {
|
||||
return i18n('GroupV2--title--remove--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--title--remove--unknown', i18n);
|
||||
return i18n('GroupV2--title--remove--unknown');
|
||||
}
|
||||
if (detail.type === 'avatar') {
|
||||
if (detail.removed) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--avatar--remove--you', i18n);
|
||||
return i18n('GroupV2--avatar--remove--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--avatar--remove--other', i18n, {
|
||||
return i18n('GroupV2--avatar--remove--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--avatar--remove--unknown', i18n);
|
||||
return i18n('GroupV2--avatar--remove--unknown');
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--avatar--change--you', i18n);
|
||||
return i18n('GroupV2--avatar--change--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--avatar--change--other', i18n, {
|
||||
return i18n('GroupV2--avatar--change--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--avatar--change--unknown', i18n);
|
||||
return i18n('GroupV2--avatar--change--unknown');
|
||||
}
|
||||
if (detail.type === 'access-attributes') {
|
||||
const { newPrivilege } = detail;
|
||||
|
||||
if (newPrivilege === AccessControlEnum.ADMINISTRATOR) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--access-attributes--admins--you', i18n);
|
||||
return i18n('GroupV2--access-attributes--admins--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--access-attributes--admins--other', i18n, {
|
||||
return i18n('GroupV2--access-attributes--admins--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--access-attributes--admins--unknown', i18n);
|
||||
return i18n('GroupV2--access-attributes--admins--unknown');
|
||||
}
|
||||
if (newPrivilege === AccessControlEnum.MEMBER) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--access-attributes--all--you', i18n);
|
||||
return i18n('GroupV2--access-attributes--all--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--access-attributes--all--other', i18n, {
|
||||
return i18n('GroupV2--access-attributes--all--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--access-attributes--all--unknown', i18n);
|
||||
return i18n('GroupV2--access-attributes--all--unknown');
|
||||
}
|
||||
log.warn(
|
||||
`access-attributes change type, privilege ${newPrivilege} is unknown`
|
||||
|
@ -172,25 +183,25 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (newPrivilege === AccessControlEnum.ADMINISTRATOR) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--access-members--admins--you', i18n);
|
||||
return i18n('GroupV2--access-members--admins--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--access-members--admins--other', i18n, {
|
||||
return i18n('GroupV2--access-members--admins--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--access-members--admins--unknown', i18n);
|
||||
return i18n('GroupV2--access-members--admins--unknown');
|
||||
}
|
||||
if (newPrivilege === AccessControlEnum.MEMBER) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--access-members--all--you', i18n);
|
||||
return i18n('GroupV2--access-members--all--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--access-members--all--other', i18n, {
|
||||
return i18n('GroupV2--access-members--all--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--access-members--all--unknown', i18n);
|
||||
return i18n('GroupV2--access-members--all--unknown');
|
||||
}
|
||||
log.warn(
|
||||
`access-members change type, privilege ${newPrivilege} is unknown`
|
||||
|
@ -202,35 +213,29 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (newPrivilege === AccessControlEnum.ADMINISTRATOR) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--access-invite-link--enabled--you', i18n);
|
||||
return i18n('GroupV2--access-invite-link--enabled--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--access-invite-link--enabled--other',
|
||||
i18n,
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--access-invite-link--enabled--unknown',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--access-invite-link--enabled--unknown');
|
||||
}
|
||||
if (newPrivilege === AccessControlEnum.ANY) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--access-invite-link--disabled--you', i18n);
|
||||
return i18n('GroupV2--access-invite-link--disabled--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--access-invite-link--disabled--other',
|
||||
i18n,
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--access-invite-link--disabled--unknown',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--access-invite-link--disabled--unknown');
|
||||
}
|
||||
log.warn(
|
||||
`access-invite-link change type, privilege ${newPrivilege} is unknown`
|
||||
|
@ -243,27 +248,27 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (weAreJoiner) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-add--you--you', i18n);
|
||||
return i18n('GroupV2--member-add--you--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-add--you--other', i18n, {
|
||||
return i18n('GroupV2--member-add--you--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-add--you--unknown', i18n);
|
||||
return i18n('GroupV2--member-add--you--unknown');
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-add--other--you', i18n, {
|
||||
return i18n('GroupV2--member-add--other--you', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-add--other--other', i18n, {
|
||||
return i18n('GroupV2--member-add--other--other', {
|
||||
adderName: renderContact(from),
|
||||
addeeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-add--other--unknown', i18n, {
|
||||
return i18n('GroupV2--member-add--other--unknown', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
|
@ -276,54 +281,51 @@ export function renderChangeDetail<T>(
|
|||
if (weAreJoiner) {
|
||||
// They can't be the same, no fromYou check here
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-add--you--other', i18n, {
|
||||
return i18n('GroupV2--member-add--you--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-add--you--unknown', i18n);
|
||||
return i18n('GroupV2--member-add--you--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-add--invited--you', i18n, {
|
||||
return i18n('GroupV2--member-add--invited--you', {
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-add--invited--other', i18n, {
|
||||
return i18n('GroupV2--member-add--invited--other', {
|
||||
memberName: renderContact(from),
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-add--invited--unknown', i18n, {
|
||||
return i18n('GroupV2--member-add--invited--unknown', {
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
|
||||
if (weAreJoiner) {
|
||||
if (inviter) {
|
||||
return renderString('GroupV2--member-add--from-invite--you', i18n, {
|
||||
return i18n('GroupV2--member-add--from-invite--you', {
|
||||
inviterName: renderContact(inviter),
|
||||
});
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--member-add--from-invite--you-no-from',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--member-add--from-invite--you-no-from');
|
||||
}
|
||||
if (weAreInviter) {
|
||||
return renderString('GroupV2--member-add--from-invite--from-you', i18n, {
|
||||
return i18n('GroupV2--member-add--from-invite--from-you', {
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (inviter) {
|
||||
return renderString('GroupV2--member-add--from-invite--other', i18n, {
|
||||
return i18n('GroupV2--member-add--from-invite--other', {
|
||||
inviteeName: renderContact(uuid),
|
||||
inviterName: renderContact(inviter),
|
||||
});
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-add--from-invite--other-no-from',
|
||||
i18n,
|
||||
|
||||
{
|
||||
inviteeName: renderContact(uuid),
|
||||
}
|
||||
|
@ -333,10 +335,10 @@ export function renderChangeDetail<T>(
|
|||
const { uuid } = detail;
|
||||
|
||||
if (fromYou && isOurUuid(uuid)) {
|
||||
return renderString('GroupV2--member-add-from-link--you--you', i18n);
|
||||
return i18n('GroupV2--member-add-from-link--you--you');
|
||||
}
|
||||
if (from && uuid === from) {
|
||||
return renderString('GroupV2--member-add-from-link--other', i18n, {
|
||||
return i18n('GroupV2--member-add-from-link--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
|
@ -344,7 +346,7 @@ export function renderChangeDetail<T>(
|
|||
// Note: this shouldn't happen, because we only capture 'add-from-link' status
|
||||
// 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, {
|
||||
return i18n('GroupV2--member-add--other--unknown', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
|
@ -354,9 +356,9 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (weAreJoiner) {
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-add-from-admin-approval--you--other',
|
||||
i18n,
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
}
|
||||
|
@ -366,23 +368,20 @@ export function renderChangeDetail<T>(
|
|||
log.warn(
|
||||
'member-add-from-admin-approval change type; we have no from, and we are joiner!'
|
||||
);
|
||||
return renderString(
|
||||
'GroupV2--member-add-from-admin-approval--you--unknown',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--member-add-from-admin-approval--you--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-add-from-admin-approval--other--you',
|
||||
i18n,
|
||||
|
||||
{ joinerName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-add-from-admin-approval--other--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(uuid),
|
||||
|
@ -393,9 +392,9 @@ export function renderChangeDetail<T>(
|
|||
// Note: this shouldn't happen, because we only capture 'add-from-admin-approval'
|
||||
// status from group change events, which always have a sender.
|
||||
log.warn('member-add-from-admin-approval change type; we have no from');
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-add-from-admin-approval--other--unknown',
|
||||
i18n,
|
||||
|
||||
{ joinerName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
|
@ -405,33 +404,33 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (weAreLeaver) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-remove--you--you', i18n);
|
||||
return i18n('GroupV2--member-remove--you--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-remove--you--other', i18n, {
|
||||
return i18n('GroupV2--member-remove--you--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-remove--you--unknown', i18n);
|
||||
return i18n('GroupV2--member-remove--you--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--member-remove--other--you', i18n, {
|
||||
return i18n('GroupV2--member-remove--other--you', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (from && from === uuid) {
|
||||
return renderString('GroupV2--member-remove--other--self', i18n, {
|
||||
return i18n('GroupV2--member-remove--other--self', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--member-remove--other--other', i18n, {
|
||||
return i18n('GroupV2--member-remove--other--other', {
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--member-remove--other--unknown', i18n, {
|
||||
return i18n('GroupV2--member-remove--other--unknown', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
|
@ -442,77 +441,59 @@ export function renderChangeDetail<T>(
|
|||
if (newPrivilege === RoleEnum.ADMINISTRATOR) {
|
||||
if (weAreMember) {
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-privilege--promote--you--other',
|
||||
i18n,
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
}
|
||||
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--promote--you--unknown',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--member-privilege--promote--you--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--promote--other--you',
|
||||
i18n,
|
||||
{ memberName: renderContact(uuid) }
|
||||
);
|
||||
return i18n('GroupV2--member-privilege--promote--other--you', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--promote--other--other',
|
||||
i18n,
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
return i18n('GroupV2--member-privilege--promote--other--other', {
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--promote--other--unknown',
|
||||
i18n,
|
||||
{ memberName: renderContact(uuid) }
|
||||
);
|
||||
return i18n('GroupV2--member-privilege--promote--other--unknown', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (newPrivilege === RoleEnum.DEFAULT) {
|
||||
if (weAreMember) {
|
||||
if (from) {
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--demote--you--other',
|
||||
i18n,
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
return i18n('GroupV2--member-privilege--demote--you--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--demote--you--unknown',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--member-privilege--demote--you--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
'GroupV2--member-privilege--demote--other--you',
|
||||
i18n,
|
||||
{ memberName: renderContact(uuid) }
|
||||
);
|
||||
return i18n('GroupV2--member-privilege--demote--other--you', {
|
||||
memberName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-privilege--demote--other--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--member-privilege--demote--other--unknown',
|
||||
i18n,
|
||||
|
||||
{ memberName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
|
@ -526,39 +507,39 @@ export function renderChangeDetail<T>(
|
|||
const weAreInvited = isOurUuid(uuid);
|
||||
if (weAreInvited) {
|
||||
if (from) {
|
||||
return renderString('GroupV2--pending-add--one--you--other', i18n, {
|
||||
return i18n('GroupV2--pending-add--one--you--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--pending-add--one--you--unknown', i18n);
|
||||
return i18n('GroupV2--pending-add--one--you--unknown');
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--pending-add--one--other--you', i18n, {
|
||||
return i18n('GroupV2--pending-add--one--other--you', {
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--pending-add--one--other--other', i18n, {
|
||||
return i18n('GroupV2--pending-add--one--other--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--pending-add--one--other--unknown', i18n);
|
||||
return i18n('GroupV2--pending-add--one--other--unknown');
|
||||
}
|
||||
if (detail.type === 'pending-add-many') {
|
||||
const { count } = detail;
|
||||
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--pending-add--many--you', i18n, {
|
||||
return i18n('GroupV2--pending-add--many--you', {
|
||||
count: count.toString(),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--pending-add--many--other', i18n, {
|
||||
return i18n('GroupV2--pending-add--many--other', {
|
||||
memberName: renderContact(from),
|
||||
count: count.toString(),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--pending-add--many--unknown', i18n, {
|
||||
return i18n('GroupV2--pending-add--many--unknown', {
|
||||
count: count.toString(),
|
||||
});
|
||||
}
|
||||
|
@ -571,91 +552,91 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (weAreInviter) {
|
||||
if (sentByInvited) {
|
||||
return renderString('GroupV2--pending-remove--decline--you', i18n, {
|
||||
return i18n('GroupV2--pending-remove--decline--you', {
|
||||
inviteeName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--one--you',
|
||||
i18n,
|
||||
|
||||
{ inviteeName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--one--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
inviteeName: renderContact(uuid),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--one--unknown',
|
||||
i18n,
|
||||
|
||||
{ inviteeName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
if (sentByInvited) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--pending-remove--decline--from-you', i18n);
|
||||
return i18n('GroupV2--pending-remove--decline--from-you');
|
||||
}
|
||||
if (inviter) {
|
||||
return renderString('GroupV2--pending-remove--decline--other', i18n, {
|
||||
return i18n('GroupV2--pending-remove--decline--other', {
|
||||
memberName: renderContact(inviter),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--pending-remove--decline--unknown', i18n);
|
||||
return i18n('GroupV2--pending-remove--decline--unknown');
|
||||
}
|
||||
if (inviter && sentByInviter) {
|
||||
if (weAreInvited) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-own--to-you',
|
||||
i18n,
|
||||
|
||||
{ inviterName: renderContact(inviter) }
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-own--unknown',
|
||||
i18n,
|
||||
|
||||
{ inviterName: renderContact(inviter) }
|
||||
);
|
||||
}
|
||||
if (inviter) {
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from--one--you',
|
||||
i18n,
|
||||
|
||||
{ memberName: renderContact(inviter) }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from--one--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(inviter),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from--one--unknown',
|
||||
i18n,
|
||||
|
||||
{ memberName: renderContact(inviter) }
|
||||
);
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--pending-remove--revoke--one--you', i18n);
|
||||
return i18n('GroupV2--pending-remove--revoke--one--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--pending-remove--revoke--one--other', i18n, {
|
||||
return i18n('GroupV2--pending-remove--revoke--one--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--pending-remove--revoke--one--unknown', i18n);
|
||||
return i18n('GroupV2--pending-remove--revoke--one--unknown');
|
||||
}
|
||||
if (detail.type === 'pending-remove-many') {
|
||||
const { count, inviter } = detail;
|
||||
|
@ -663,33 +644,33 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (weAreInviter) {
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--many--you',
|
||||
i18n,
|
||||
|
||||
{ count: count.toString() }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--many--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
count: count.toString(),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from-you--many--unknown',
|
||||
i18n,
|
||||
|
||||
{ count: count.toString() }
|
||||
);
|
||||
}
|
||||
if (inviter) {
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from--many--you',
|
||||
i18n,
|
||||
|
||||
{
|
||||
count: count.toString(),
|
||||
memberName: renderContact(inviter),
|
||||
|
@ -697,9 +678,9 @@ export function renderChangeDetail<T>(
|
|||
);
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from--many--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
count: count.toString(),
|
||||
|
@ -707,9 +688,9 @@ export function renderChangeDetail<T>(
|
|||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke-invite-from--many--unknown',
|
||||
i18n,
|
||||
|
||||
{
|
||||
count: count.toString(),
|
||||
memberName: renderContact(inviter),
|
||||
|
@ -717,23 +698,23 @@ export function renderChangeDetail<T>(
|
|||
);
|
||||
}
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--pending-remove--revoke--many--you', i18n, {
|
||||
return i18n('GroupV2--pending-remove--revoke--many--you', {
|
||||
count: count.toString(),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke--many--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
memberName: renderContact(from),
|
||||
count: count.toString(),
|
||||
}
|
||||
);
|
||||
}
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--pending-remove--revoke--many--unknown',
|
||||
i18n,
|
||||
|
||||
{ count: count.toString() }
|
||||
);
|
||||
}
|
||||
|
@ -742,9 +723,9 @@ export function renderChangeDetail<T>(
|
|||
const weAreJoiner = isOurUuid(uuid);
|
||||
|
||||
if (weAreJoiner) {
|
||||
return renderString('GroupV2--admin-approval-add-one--you', i18n);
|
||||
return i18n('GroupV2--admin-approval-add-one--you');
|
||||
}
|
||||
return renderString('GroupV2--admin-approval-add-one--other', i18n, {
|
||||
return i18n('GroupV2--admin-approval-add-one--other', {
|
||||
joinerName: renderContact(uuid),
|
||||
});
|
||||
}
|
||||
|
@ -754,35 +735,29 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (weAreJoiner) {
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
'GroupV2--admin-approval-remove-one--you--you',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--admin-approval-remove-one--you--you');
|
||||
}
|
||||
return renderString(
|
||||
'GroupV2--admin-approval-remove-one--you--unknown',
|
||||
i18n
|
||||
);
|
||||
return i18n('GroupV2--admin-approval-remove-one--you--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--admin-approval-remove-one--other--you',
|
||||
i18n,
|
||||
|
||||
{ joinerName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
if (from && from === uuid) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--admin-approval-remove-one--other--own',
|
||||
i18n,
|
||||
|
||||
{ joinerName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--admin-approval-remove-one--other--other',
|
||||
i18n,
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(uuid),
|
||||
|
@ -792,9 +767,9 @@ export function renderChangeDetail<T>(
|
|||
|
||||
// We default to the user canceling their request, because it is far more likely that
|
||||
// if an admin does the denial, we'll get a change event from them.
|
||||
return renderString(
|
||||
return i18n(
|
||||
'GroupV2--admin-approval-remove-one--other--own',
|
||||
i18n,
|
||||
|
||||
{ joinerName: renderContact(uuid) }
|
||||
);
|
||||
}
|
||||
|
@ -803,11 +778,11 @@ export function renderChangeDetail<T>(
|
|||
|
||||
let firstMessage: T | string;
|
||||
if (times === 1) {
|
||||
firstMessage = renderString('GroupV2--admin-approval-bounce--one', i18n, {
|
||||
firstMessage = i18n('GroupV2--admin-approval-bounce--one', {
|
||||
joinerName: renderContact(uuid),
|
||||
});
|
||||
} else {
|
||||
firstMessage = renderString('GroupV2--admin-approval-bounce', i18n, {
|
||||
firstMessage = i18n('GroupV2--admin-approval-bounce', {
|
||||
joinerName: renderContact(uuid),
|
||||
numberOfRequests: String(times),
|
||||
});
|
||||
|
@ -835,99 +810,99 @@ export function renderChangeDetail<T>(
|
|||
|
||||
if (privilege === AccessControlEnum.ADMINISTRATOR) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--group-link-add--enabled--you', i18n);
|
||||
return i18n('GroupV2--group-link-add--enabled--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--group-link-add--enabled--other', i18n, {
|
||||
return i18n('GroupV2--group-link-add--enabled--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--group-link-add--enabled--unknown', i18n);
|
||||
return i18n('GroupV2--group-link-add--enabled--unknown');
|
||||
}
|
||||
if (privilege === AccessControlEnum.ANY) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--group-link-add--disabled--you', i18n);
|
||||
return i18n('GroupV2--group-link-add--disabled--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--group-link-add--disabled--other', i18n, {
|
||||
return i18n('GroupV2--group-link-add--disabled--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--group-link-add--disabled--unknown', i18n);
|
||||
return i18n('GroupV2--group-link-add--disabled--unknown');
|
||||
}
|
||||
log.warn(`group-link-add change type, privilege ${privilege} is unknown`);
|
||||
return '';
|
||||
}
|
||||
if (detail.type === 'group-link-reset') {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--group-link-reset--you', i18n);
|
||||
return i18n('GroupV2--group-link-reset--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--group-link-reset--other', i18n, {
|
||||
return i18n('GroupV2--group-link-reset--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--group-link-reset--unknown', i18n);
|
||||
return i18n('GroupV2--group-link-reset--unknown');
|
||||
}
|
||||
if (detail.type === 'group-link-remove') {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--group-link-remove--you', i18n);
|
||||
return i18n('GroupV2--group-link-remove--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--group-link-remove--other', i18n, {
|
||||
return i18n('GroupV2--group-link-remove--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--group-link-remove--unknown', i18n);
|
||||
return i18n('GroupV2--group-link-remove--unknown');
|
||||
}
|
||||
if (detail.type === 'description') {
|
||||
if (detail.removed) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--description--remove--you', i18n);
|
||||
return i18n('GroupV2--description--remove--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--description--remove--other', i18n, {
|
||||
return i18n('GroupV2--description--remove--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--description--remove--unknown', i18n);
|
||||
return i18n('GroupV2--description--remove--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--description--change--you', i18n);
|
||||
return i18n('GroupV2--description--change--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--description--change--other', i18n, {
|
||||
return i18n('GroupV2--description--change--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--description--change--unknown', i18n);
|
||||
return i18n('GroupV2--description--change--unknown');
|
||||
}
|
||||
if (detail.type === 'announcements-only') {
|
||||
if (detail.announcementsOnly) {
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--announcements--admin--you', i18n);
|
||||
return i18n('GroupV2--announcements--admin--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--announcements--admin--other', i18n, {
|
||||
return i18n('GroupV2--announcements--admin--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--announcements--admin--unknown', i18n);
|
||||
return i18n('GroupV2--announcements--admin--unknown');
|
||||
}
|
||||
|
||||
if (fromYou) {
|
||||
return renderString('GroupV2--announcements--member--you', i18n);
|
||||
return i18n('GroupV2--announcements--member--you');
|
||||
}
|
||||
if (from) {
|
||||
return renderString('GroupV2--announcements--member--other', i18n, {
|
||||
return i18n('GroupV2--announcements--member--other', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return renderString('GroupV2--announcements--member--unknown', i18n);
|
||||
return i18n('GroupV2--announcements--member--unknown');
|
||||
}
|
||||
if (detail.type === 'summary') {
|
||||
return renderString('icu:GroupV2--summary', i18n);
|
||||
return i18n('icu:GroupV2--summary');
|
||||
}
|
||||
|
||||
throw missingCaseError(detail);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue