Backups: Handle groupV2 notifications
This commit is contained in:
parent
4c4ab306eb
commit
5df8924197
27 changed files with 4563 additions and 301 deletions
|
@ -37,6 +37,10 @@ export type RenderOptionsType<T extends string | JSX.Element> = {
|
|||
ourAci: AciString | undefined;
|
||||
ourPni: PniString | undefined;
|
||||
renderContact: SmartContactRendererType<T>;
|
||||
checkServiceIdEquivalence(
|
||||
left: ServiceIdString | undefined,
|
||||
right: ServiceIdString | undefined
|
||||
): boolean;
|
||||
renderIntl: StringRendererType<T>;
|
||||
};
|
||||
|
||||
|
@ -83,6 +87,7 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
options: RenderOptionsType<T>
|
||||
): string | T | ReadonlyArray<string | T> {
|
||||
const {
|
||||
checkServiceIdEquivalence,
|
||||
from,
|
||||
i18n: localizer,
|
||||
ourAci,
|
||||
|
@ -243,11 +248,9 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
return i18n('icu:GroupV2--access-invite-link--enabled--you');
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--access-invite-link--enabled--other',
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
return i18n('icu:GroupV2--access-invite-link--enabled--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return i18n('icu:GroupV2--access-invite-link--enabled--unknown');
|
||||
}
|
||||
|
@ -256,11 +259,9 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
return i18n('icu:GroupV2--access-invite-link--disabled--you');
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--access-invite-link--disabled--other',
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
return i18n('icu:GroupV2--access-invite-link--disabled--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
return i18n('icu:GroupV2--access-invite-link--disabled--unknown');
|
||||
}
|
||||
|
@ -304,7 +305,7 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
const weAreJoiner = isOurServiceId(aci);
|
||||
const weAreInviter = isOurServiceId(inviter);
|
||||
|
||||
if (!from || from !== aci) {
|
||||
if (!from || !checkServiceIdEquivalence(from, aci)) {
|
||||
if (weAreJoiner) {
|
||||
// They can't be the same, no fromYou check here
|
||||
if (from) {
|
||||
|
@ -350,13 +351,9 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
inviterName: renderContact(inviter),
|
||||
});
|
||||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--member-add--from-invite--other-no-from',
|
||||
|
||||
{
|
||||
inviteeName: renderContact(aci),
|
||||
}
|
||||
);
|
||||
return i18n('icu:GroupV2--member-add--from-invite--other-no-from', {
|
||||
inviteeName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
if (detail.type === 'member-add-from-link') {
|
||||
const { aci } = detail;
|
||||
|
@ -383,11 +380,9 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
|
||||
if (weAreJoiner) {
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--member-add-from-admin-approval--you--other',
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
return i18n('icu:GroupV2--member-add-from-admin-approval--you--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
|
||||
// Note: this shouldn't happen, because we only capture 'add-from-admin-approval'
|
||||
|
@ -399,31 +394,23 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
}
|
||||
|
||||
if (fromYou) {
|
||||
return i18n(
|
||||
'icu:GroupV2--member-add-from-admin-approval--other--you',
|
||||
|
||||
{ joinerName: renderContact(aci) }
|
||||
);
|
||||
return i18n('icu:GroupV2--member-add-from-admin-approval--other--you', {
|
||||
joinerName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--member-add-from-admin-approval--other--other',
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(aci),
|
||||
}
|
||||
);
|
||||
return i18n('icu:GroupV2--member-add-from-admin-approval--other--other', {
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
|
||||
// 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 i18n(
|
||||
'icu:GroupV2--member-add-from-admin-approval--other--unknown',
|
||||
|
||||
{ joinerName: renderContact(aci) }
|
||||
);
|
||||
return i18n('icu:GroupV2--member-add-from-admin-approval--other--unknown', {
|
||||
joinerName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
if (detail.type === 'member-remove') {
|
||||
const { aci } = detail;
|
||||
|
@ -446,7 +433,7 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
memberName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
if (from && from === aci) {
|
||||
if (from && fromYou) {
|
||||
return i18n('icu:GroupV2--member-remove--other--self', {
|
||||
memberName: renderContact(from),
|
||||
});
|
||||
|
@ -468,11 +455,9 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
if (newPrivilege === RoleEnum.ADMINISTRATOR) {
|
||||
if (weAreMember) {
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--member-privilege--promote--you--other',
|
||||
|
||||
{ adminName: renderContact(from) }
|
||||
);
|
||||
return i18n('icu:GroupV2--member-privilege--promote--you--other', {
|
||||
adminName: renderContact(from),
|
||||
});
|
||||
}
|
||||
|
||||
return i18n('icu:GroupV2--member-privilege--promote--you--unknown');
|
||||
|
@ -509,20 +494,14 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
});
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--member-privilege--demote--other--other',
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(aci),
|
||||
}
|
||||
);
|
||||
return i18n('icu:GroupV2--member-privilege--demote--other--other', {
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--member-privilege--demote--other--unknown',
|
||||
|
||||
{ memberName: renderContact(aci) }
|
||||
);
|
||||
return i18n('icu:GroupV2--member-privilege--demote--other--unknown', {
|
||||
memberName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
log.warn(
|
||||
`member-privilege change type, privilege ${newPrivilege} is unknown`
|
||||
|
@ -586,14 +565,12 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
if (fromYou) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from-you--one--you',
|
||||
|
||||
{ inviteeName: renderContact(serviceId) }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from-you--one--other',
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
inviteeName: renderContact(serviceId),
|
||||
|
@ -602,7 +579,6 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from-you--one--unknown',
|
||||
|
||||
{ inviteeName: renderContact(serviceId) }
|
||||
);
|
||||
}
|
||||
|
@ -619,30 +595,24 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
}
|
||||
if (inviter && sentByInviter) {
|
||||
if (weAreInvited) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-own--to-you',
|
||||
|
||||
{ inviterName: renderContact(inviter) }
|
||||
);
|
||||
return i18n('icu:GroupV2--pending-remove--revoke-own--to-you', {
|
||||
inviterName: renderContact(inviter),
|
||||
});
|
||||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-own--unknown',
|
||||
|
||||
{ inviterName: renderContact(inviter) }
|
||||
);
|
||||
return i18n('icu:GroupV2--pending-remove--revoke-own--unknown', {
|
||||
inviterName: renderContact(inviter),
|
||||
});
|
||||
}
|
||||
if (inviter) {
|
||||
if (fromYou) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from--one--you',
|
||||
|
||||
{ memberName: renderContact(inviter) }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from--one--other',
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
memberName: renderContact(inviter),
|
||||
|
@ -651,7 +621,6 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from--one--unknown',
|
||||
|
||||
{ memberName: renderContact(inviter) }
|
||||
);
|
||||
}
|
||||
|
@ -673,14 +642,12 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
if (fromYou) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from-you--many--you',
|
||||
|
||||
{ count }
|
||||
);
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from-you--many--other',
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
count,
|
||||
|
@ -689,7 +656,6 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from-you--many--unknown',
|
||||
|
||||
{ count }
|
||||
);
|
||||
}
|
||||
|
@ -697,7 +663,6 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
if (fromYou) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from--many--you',
|
||||
|
||||
{
|
||||
count,
|
||||
memberName: renderContact(inviter),
|
||||
|
@ -707,7 +672,6 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from--many--other',
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
count,
|
||||
|
@ -717,7 +681,6 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke-invite-from--many--unknown',
|
||||
|
||||
{
|
||||
count,
|
||||
memberName: renderContact(inviter),
|
||||
|
@ -730,20 +693,14 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
});
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke--many--other',
|
||||
|
||||
{
|
||||
memberName: renderContact(from),
|
||||
count,
|
||||
}
|
||||
);
|
||||
return i18n('icu:GroupV2--pending-remove--revoke--many--other', {
|
||||
memberName: renderContact(from),
|
||||
count,
|
||||
});
|
||||
}
|
||||
return i18n(
|
||||
'icu:GroupV2--pending-remove--revoke--many--unknown',
|
||||
|
||||
{ count }
|
||||
);
|
||||
return i18n('icu:GroupV2--pending-remove--revoke--many--unknown', {
|
||||
count,
|
||||
});
|
||||
}
|
||||
if (detail.type === 'admin-approval-add-one') {
|
||||
const { aci } = detail;
|
||||
|
@ -768,35 +725,25 @@ function renderChangeDetail<T extends string | JSX.Element>(
|
|||
}
|
||||
|
||||
if (fromYou) {
|
||||
return i18n(
|
||||
'icu:GroupV2--admin-approval-remove-one--other--you',
|
||||
|
||||
{ joinerName: renderContact(aci) }
|
||||
);
|
||||
return i18n('icu:GroupV2--admin-approval-remove-one--other--you', {
|
||||
joinerName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
if (from && from === aci) {
|
||||
return i18n(
|
||||
'icu:GroupV2--admin-approval-remove-one--other--own',
|
||||
|
||||
{ joinerName: renderContact(aci) }
|
||||
);
|
||||
if (from && fromYou) {
|
||||
return i18n('icu:GroupV2--admin-approval-remove-one--other--own', {
|
||||
joinerName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
if (from) {
|
||||
return i18n(
|
||||
'icu:GroupV2--admin-approval-remove-one--other--other',
|
||||
|
||||
{
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(aci),
|
||||
}
|
||||
);
|
||||
return i18n('icu:GroupV2--admin-approval-remove-one--other--other', {
|
||||
adminName: renderContact(from),
|
||||
joinerName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
|
||||
return i18n(
|
||||
'icu:GroupV2--admin-approval-remove-one--other--unknown',
|
||||
|
||||
{ joinerName: renderContact(aci) }
|
||||
);
|
||||
return i18n('icu:GroupV2--admin-approval-remove-one--other--unknown', {
|
||||
joinerName: renderContact(aci),
|
||||
});
|
||||
}
|
||||
if (detail.type === 'admin-approval-bounce') {
|
||||
const { aci, times, isApprovalPending } = detail;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue