2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from './types/Util';
|
|
|
|
import type { ReplacementValuesType } from './types/I18N';
|
2023-08-10 16:43:33 +00:00
|
|
|
import type { ServiceIdString, AciString, PniString } from './types/ServiceId';
|
2020-09-09 02:25:05 +00:00
|
|
|
import { missingCaseError } from './util/missingCaseError';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { GroupV2ChangeDetailType, GroupV2ChangeType } from './groups';
|
2021-07-09 19:36:10 +00:00
|
|
|
import { SignalService as Proto } from './protobuf';
|
2021-09-17 18:27:53 +00:00
|
|
|
import * as log from './logging/log';
|
2020-09-09 02:25:05 +00:00
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
export type SmartContactRendererType<T> = (
|
|
|
|
serviceId: ServiceIdString
|
|
|
|
) => T | string;
|
2021-12-16 17:44:54 +00:00
|
|
|
export type StringRendererType<T> = (
|
2020-09-09 02:25:05 +00:00
|
|
|
id: string,
|
|
|
|
i18n: LocalizerType,
|
2023-04-03 19:03:00 +00:00
|
|
|
components?: ReplacementValuesType<T | string | number>
|
2021-12-16 17:44:54 +00:00
|
|
|
) => T | string;
|
2020-09-09 02:25:05 +00:00
|
|
|
|
2021-12-16 17:44:54 +00:00
|
|
|
export type RenderOptionsType<T> = {
|
2023-08-10 16:43:33 +00:00
|
|
|
// `from` will be a PNI when the change is "declining a PNI invite".
|
|
|
|
from?: ServiceIdString;
|
2020-09-09 02:25:05 +00:00
|
|
|
i18n: LocalizerType;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourAci: AciString | undefined;
|
|
|
|
ourPni: PniString | undefined;
|
2021-12-16 17:44:54 +00:00
|
|
|
renderContact: SmartContactRendererType<T>;
|
|
|
|
renderString: StringRendererType<T>;
|
2020-09-09 02:25:05 +00:00
|
|
|
};
|
|
|
|
|
2021-07-09 19:36:10 +00:00
|
|
|
const AccessControlEnum = Proto.AccessControl.AccessRequired;
|
|
|
|
const RoleEnum = Proto.Member.Role;
|
|
|
|
|
2022-03-16 00:11:28 +00:00
|
|
|
export type RenderChangeResultType<T> = ReadonlyArray<
|
|
|
|
Readonly<{
|
|
|
|
detail: GroupV2ChangeDetailType;
|
|
|
|
text: T | string;
|
|
|
|
|
|
|
|
// Used to differentiate between the multiple texts produced by
|
|
|
|
// 'admin-approval-bounce'
|
|
|
|
isLastText: boolean;
|
|
|
|
}>
|
|
|
|
>;
|
|
|
|
|
2021-12-16 17:44:54 +00:00
|
|
|
export function renderChange<T>(
|
2020-09-09 02:25:05 +00:00
|
|
|
change: GroupV2ChangeType,
|
2021-12-16 17:44:54 +00:00
|
|
|
options: RenderOptionsType<T>
|
2022-03-16 00:11:28 +00:00
|
|
|
): RenderChangeResultType<T> {
|
2020-09-09 02:25:05 +00:00
|
|
|
const { details, from } = change;
|
|
|
|
|
2022-03-16 00:11:28 +00:00
|
|
|
return details.flatMap((detail: GroupV2ChangeDetailType) => {
|
|
|
|
const texts = renderChangeDetail<T>(detail, {
|
2020-09-09 02:25:05 +00:00
|
|
|
...options,
|
|
|
|
from,
|
2022-03-16 00:11:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!Array.isArray(texts)) {
|
|
|
|
return { detail, isLastText: true, text: texts };
|
|
|
|
}
|
|
|
|
|
|
|
|
return texts.map((text, index) => {
|
|
|
|
const isLastText = index === texts.length - 1;
|
|
|
|
return { detail, isLastText, text };
|
|
|
|
});
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
|
|
|
|
2021-12-16 17:44:54 +00:00
|
|
|
export function renderChangeDetail<T>(
|
2020-09-09 02:25:05 +00:00
|
|
|
detail: GroupV2ChangeDetailType,
|
2021-12-16 17:44:54 +00:00
|
|
|
options: RenderOptionsType<T>
|
2022-03-16 00:11:28 +00:00
|
|
|
): T | string | ReadonlyArray<T | string> {
|
2023-03-29 17:15:54 +00:00
|
|
|
const {
|
|
|
|
from,
|
|
|
|
i18n: localizer,
|
2023-08-10 16:43:33 +00:00
|
|
|
ourAci,
|
|
|
|
ourPni,
|
2023-03-29 17:15:54 +00:00
|
|
|
renderContact,
|
|
|
|
renderString,
|
|
|
|
} = options;
|
|
|
|
|
2023-04-03 19:03:00 +00:00
|
|
|
function i18n(
|
|
|
|
id: string,
|
|
|
|
components?: ReplacementValuesType<T | number | string>
|
|
|
|
) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return renderString(id, localizer, components);
|
|
|
|
}
|
2022-07-08 20:46:25 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
const isOurServiceId = (serviceId?: ServiceIdString): boolean => {
|
|
|
|
if (!serviceId) {
|
2022-07-08 20:46:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-16 20:54:39 +00:00
|
|
|
return Boolean(
|
|
|
|
(ourAci && serviceId === ourAci) || (ourPni && serviceId === ourPni)
|
|
|
|
);
|
2022-07-08 20:46:25 +00:00
|
|
|
};
|
2023-08-16 20:54:39 +00:00
|
|
|
const fromYou = isOurServiceId(from);
|
2020-09-09 02:25:05 +00:00
|
|
|
|
2020-10-06 17:06:34 +00:00
|
|
|
if (detail.type === 'create') {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--create--you');
|
2020-10-06 17:06:34 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--create--other', {
|
2020-10-06 17:06:34 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--create--unknown');
|
2020-10-06 17:06:34 +00:00
|
|
|
}
|
2020-09-09 02:25:05 +00:00
|
|
|
if (detail.type === 'title') {
|
|
|
|
const { newTitle } = detail;
|
|
|
|
|
|
|
|
if (newTitle) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--title--change--you', { newTitle });
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--title--change--other', {
|
2020-09-09 02:25:05 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
newTitle,
|
|
|
|
});
|
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--title--change--unknown', {
|
2023-03-27 23:37:39 +00:00
|
|
|
newTitle,
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--title--remove--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--title--remove--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--title--remove--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'avatar') {
|
2020-09-09 02:25:05 +00:00
|
|
|
if (detail.removed) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--avatar--remove--you');
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--avatar--remove--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--avatar--remove--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--avatar--change--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--avatar--change--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--avatar--change--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'access-attributes') {
|
2020-09-09 02:25:05 +00:00
|
|
|
const { newPrivilege } = detail;
|
|
|
|
|
|
|
|
if (newPrivilege === AccessControlEnum.ADMINISTRATOR) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-attributes--admins--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-attributes--admins--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-attributes--admins--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (newPrivilege === AccessControlEnum.MEMBER) {
|
2020-09-09 02:25:05 +00:00
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-attributes--all--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-attributes--all--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-attributes--all--unknown');
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2020-09-11 19:37:01 +00:00
|
|
|
`access-attributes change type, privilege ${newPrivilege} is unknown`
|
|
|
|
);
|
2020-12-18 19:27:43 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (detail.type === 'access-members') {
|
2020-09-09 02:25:05 +00:00
|
|
|
const { newPrivilege } = detail;
|
|
|
|
|
|
|
|
if (newPrivilege === AccessControlEnum.ADMINISTRATOR) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-members--admins--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-members--admins--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-members--admins--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (newPrivilege === AccessControlEnum.MEMBER) {
|
2020-09-09 02:25:05 +00:00
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-members--all--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-members--all--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-members--all--unknown');
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2020-09-11 19:37:01 +00:00
|
|
|
`access-members change type, privilege ${newPrivilege} is unknown`
|
|
|
|
);
|
2020-12-18 19:27:43 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (detail.type === 'access-invite-link') {
|
|
|
|
const { newPrivilege } = detail;
|
|
|
|
|
|
|
|
if (newPrivilege === AccessControlEnum.ADMINISTRATOR) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-invite-link--enabled--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--access-invite-link--enabled--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ adminName: renderContact(from) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-invite-link--enabled--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (newPrivilege === AccessControlEnum.ANY) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-invite-link--disabled--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--access-invite-link--disabled--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ adminName: renderContact(from) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--access-invite-link--disabled--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2020-12-18 19:27:43 +00:00
|
|
|
`access-invite-link change type, privilege ${newPrivilege} is unknown`
|
|
|
|
);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (detail.type === 'member-add') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci } = detail;
|
|
|
|
const weAreJoiner = isOurServiceId(aci);
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
if (weAreJoiner) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--you--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--you--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--you--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--other--you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--other--other', {
|
2020-09-11 19:37:01 +00:00
|
|
|
adderName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
addeeName: renderContact(aci),
|
2020-09-11 19:37:01 +00:00
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--other--unknown', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'member-add-from-invite') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci, inviter } = detail;
|
|
|
|
const weAreJoiner = isOurServiceId(aci);
|
|
|
|
const weAreInviter = isOurServiceId(inviter);
|
2020-09-09 02:25:05 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
if (!from || from !== aci) {
|
2020-09-28 17:22:57 +00:00
|
|
|
if (weAreJoiner) {
|
|
|
|
// They can't be the same, no fromYou check here
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--you--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-28 17:22:57 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--you--unknown');
|
2020-09-28 17:22:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--invited--you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(aci),
|
2020-09-28 17:22:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--invited--other', {
|
2020-09-28 17:22:57 +00:00
|
|
|
memberName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(aci),
|
2020-09-28 17:22:57 +00:00
|
|
|
});
|
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--invited--unknown', {
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(aci),
|
2020-09-28 17:22:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
if (weAreJoiner) {
|
2020-09-28 17:22:57 +00:00
|
|
|
if (inviter) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--from-invite--you', {
|
2023-03-27 23:37:39 +00:00
|
|
|
inviterName: renderContact(inviter),
|
|
|
|
});
|
2020-09-28 17:22:57 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--from-invite--you-no-from');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (weAreInviter) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--from-invite--from-you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(aci),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-28 17:22:57 +00:00
|
|
|
if (inviter) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--from-invite--other', {
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(aci),
|
2020-09-28 17:22:57 +00:00
|
|
|
inviterName: renderContact(inviter),
|
|
|
|
});
|
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-add--from-invite--other-no-from',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-28 17:22:57 +00:00
|
|
|
{
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(aci),
|
2020-09-28 17:22:57 +00:00
|
|
|
}
|
|
|
|
);
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'member-add-from-link') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci } = detail;
|
2020-12-18 19:27:43 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
if (fromYou && isOurServiceId(aci)) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add-from-link--you--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2023-08-16 20:54:39 +00:00
|
|
|
if (from && aci === from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add-from-link--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Note: this shouldn't happen, because we only capture 'add-from-link' status
|
|
|
|
// from group change events, which always have a sender.
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn('member-add-from-link change type; we have no from!');
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add--other--unknown', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'member-add-from-admin-approval') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci } = detail;
|
|
|
|
const weAreJoiner = isOurServiceId(aci);
|
2020-12-18 19:27:43 +00:00
|
|
|
|
|
|
|
if (weAreJoiner) {
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-add-from-admin-approval--you--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ adminName: renderContact(from) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: this shouldn't happen, because we only capture 'add-from-admin-approval'
|
|
|
|
// status from group change events, which always have a sender.
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2020-12-18 19:27:43 +00:00
|
|
|
'member-add-from-admin-approval change type; we have no from, and we are joiner!'
|
|
|
|
);
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-add-from-admin-approval--you--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-add-from-admin-approval--other--you',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ joinerName: renderContact(aci) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-add-from-admin-approval--other--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-12-18 19:27:43 +00:00
|
|
|
{
|
|
|
|
adminName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
joinerName: renderContact(aci),
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: this shouldn't happen, because we only capture 'add-from-admin-approval'
|
|
|
|
// status from group change events, which always have a sender.
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn('member-add-from-admin-approval change type; we have no from');
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-add-from-admin-approval--other--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ joinerName: renderContact(aci) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (detail.type === 'member-remove') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci } = detail;
|
|
|
|
const weAreLeaver = isOurServiceId(aci);
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
if (weAreLeaver) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-remove--you--you');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-remove--you--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-remove--you--unknown');
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-remove--other--you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
2023-08-16 20:54:39 +00:00
|
|
|
if (from && from === aci) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-remove--other--self', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-remove--other--other', {
|
2020-09-11 19:37:01 +00:00
|
|
|
adminName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2020-09-11 19:37:01 +00:00
|
|
|
});
|
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-remove--other--unknown', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'member-privilege') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci, newPrivilege } = detail;
|
|
|
|
const weAreMember = isOurServiceId(aci);
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
if (newPrivilege === RoleEnum.ADMINISTRATOR) {
|
|
|
|
if (weAreMember) {
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-privilege--promote--you--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ adminName: renderContact(from) }
|
2020-09-09 02:25:05 +00:00
|
|
|
);
|
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-privilege--promote--you--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-privilege--promote--other--you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-29 17:15:54 +00:00
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-privilege--promote--other--other', {
|
2023-03-29 17:15:54 +00:00
|
|
|
adminName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-29 17:15:54 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-privilege--promote--other--unknown', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-29 17:15:54 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (newPrivilege === RoleEnum.DEFAULT) {
|
2020-09-09 02:25:05 +00:00
|
|
|
if (weAreMember) {
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-privilege--demote--you--other', {
|
2023-03-29 17:15:54 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-privilege--demote--you--unknown');
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--member-privilege--demote--other--you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2023-03-29 17:15:54 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-privilege--demote--other--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-11 19:37:01 +00:00
|
|
|
{
|
|
|
|
adminName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
memberName: renderContact(aci),
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--member-privilege--demote--other--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ memberName: renderContact(aci) }
|
2020-09-09 02:25:05 +00:00
|
|
|
);
|
|
|
|
}
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2020-09-11 19:37:01 +00:00
|
|
|
`member-privilege change type, privilege ${newPrivilege} is unknown`
|
|
|
|
);
|
2020-12-18 19:27:43 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (detail.type === 'pending-add-one') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { serviceId } = detail;
|
|
|
|
const weAreInvited = isOurServiceId(serviceId);
|
2020-09-09 02:25:05 +00:00
|
|
|
if (weAreInvited) {
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--one--you--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--one--you--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--one--other--you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(serviceId),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--one--other--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--one--other--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'pending-add-many') {
|
2020-09-09 02:25:05 +00:00
|
|
|
const { count } = detail;
|
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--many--you', {
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--many--other', {
|
2020-09-09 02:25:05 +00:00
|
|
|
memberName: renderContact(from),
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2020-09-09 02:25:05 +00:00
|
|
|
});
|
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-add--many--unknown', {
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'pending-remove-one') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { inviter, serviceId } = detail;
|
|
|
|
const weAreInviter = isOurServiceId(inviter);
|
|
|
|
const weAreInvited = isOurServiceId(serviceId);
|
|
|
|
const sentByInvited = Boolean(from && from === serviceId);
|
2020-10-06 17:06:34 +00:00
|
|
|
const sentByInviter = Boolean(from && inviter && from === inviter);
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
if (weAreInviter) {
|
2020-10-06 17:06:34 +00:00
|
|
|
if (sentByInvited) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--decline--you', {
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(serviceId),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (fromYou) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from-you--one--you',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ inviteeName: renderContact(serviceId) }
|
2020-09-09 02:25:05 +00:00
|
|
|
);
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from-you--one--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
{
|
|
|
|
adminName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
inviteeName: renderContact(serviceId),
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from-you--one--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ inviteeName: renderContact(serviceId) }
|
2020-09-11 19:37:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (sentByInvited) {
|
2020-10-06 17:06:34 +00:00
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--decline--from-you');
|
2020-10-06 17:06:34 +00:00
|
|
|
}
|
2020-09-09 02:25:05 +00:00
|
|
|
if (inviter) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--decline--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(inviter),
|
|
|
|
});
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--decline--unknown');
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
2020-10-06 17:06:34 +00:00
|
|
|
if (inviter && sentByInviter) {
|
|
|
|
if (weAreInvited) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-own--to-you',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ inviterName: renderContact(inviter) }
|
2020-10-06 17:06:34 +00:00
|
|
|
);
|
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-own--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ inviterName: renderContact(inviter) }
|
2020-10-06 17:06:34 +00:00
|
|
|
);
|
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
if (inviter) {
|
2020-09-09 02:25:05 +00:00
|
|
|
if (fromYou) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from--one--you',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ memberName: renderContact(inviter) }
|
2020-09-09 02:25:05 +00:00
|
|
|
);
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from--one--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
{
|
|
|
|
adminName: renderContact(from),
|
|
|
|
memberName: renderContact(inviter),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from--one--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-03-27 23:37:39 +00:00
|
|
|
{ memberName: renderContact(inviter) }
|
2020-09-11 19:37:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--revoke--one--you');
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-09-11 19:37:01 +00:00
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--revoke--one--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--revoke--one--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'pending-remove-many') {
|
2020-09-09 02:25:05 +00:00
|
|
|
const { count, inviter } = detail;
|
2023-08-16 20:54:39 +00:00
|
|
|
const weAreInviter = isOurServiceId(inviter);
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
if (weAreInviter) {
|
|
|
|
if (fromYou) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from-you--many--you',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-04-03 19:03:00 +00:00
|
|
|
{ count }
|
2020-09-09 02:25:05 +00:00
|
|
|
);
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from-you--many--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
{
|
|
|
|
adminName: renderContact(from),
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from-you--many--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-04-03 19:03:00 +00:00
|
|
|
{ count }
|
2020-09-11 19:37:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (inviter) {
|
2020-09-09 02:25:05 +00:00
|
|
|
if (fromYou) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from--many--you',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
{
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2020-09-09 02:25:05 +00:00
|
|
|
memberName: renderContact(inviter),
|
|
|
|
}
|
|
|
|
);
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from--many--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
{
|
|
|
|
adminName: renderContact(from),
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2020-09-09 02:25:05 +00:00
|
|
|
memberName: renderContact(inviter),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke-invite-from--many--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-11 19:37:01 +00:00
|
|
|
{
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2020-09-11 19:37:01 +00:00
|
|
|
memberName: renderContact(inviter),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--pending-remove--revoke--many--you', {
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke--many--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-09-11 19:37:01 +00:00
|
|
|
{
|
|
|
|
memberName: renderContact(from),
|
2023-04-03 19:03:00 +00:00
|
|
|
count,
|
2020-09-11 19:37:01 +00:00
|
|
|
}
|
|
|
|
);
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--pending-remove--revoke--many--unknown',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-04-03 19:03:00 +00:00
|
|
|
{ count }
|
2020-09-11 19:37:01 +00:00
|
|
|
);
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|
2020-12-18 19:27:43 +00:00
|
|
|
if (detail.type === 'admin-approval-add-one') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci } = detail;
|
|
|
|
const weAreJoiner = isOurServiceId(aci);
|
2020-12-18 19:27:43 +00:00
|
|
|
|
|
|
|
if (weAreJoiner) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--admin-approval-add-one--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--admin-approval-add-one--other', {
|
2023-08-16 20:54:39 +00:00
|
|
|
joinerName: renderContact(aci),
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'admin-approval-remove-one') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci } = detail;
|
|
|
|
const weAreJoiner = isOurServiceId(aci);
|
2020-12-18 19:27:43 +00:00
|
|
|
|
|
|
|
if (weAreJoiner) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--admin-approval-remove-one--you--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--admin-approval-remove-one--you--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--admin-approval-remove-one--other--you',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ joinerName: renderContact(aci) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
2023-08-16 20:54:39 +00:00
|
|
|
if (from && from === aci) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--admin-approval-remove-one--other--own',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ joinerName: renderContact(aci) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--admin-approval-remove-one--other--other',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2020-12-18 19:27:43 +00:00
|
|
|
{
|
|
|
|
adminName: renderContact(from),
|
2023-08-16 20:54:39 +00:00
|
|
|
joinerName: renderContact(aci),
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:GroupV2--admin-approval-remove-one--other--own',
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
{ joinerName: renderContact(aci) }
|
2020-12-18 19:27:43 +00:00
|
|
|
);
|
|
|
|
}
|
2022-03-16 00:11:28 +00:00
|
|
|
if (detail.type === 'admin-approval-bounce') {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci, times, isApprovalPending } = detail;
|
2022-03-16 00:11:28 +00:00
|
|
|
|
|
|
|
let firstMessage: T | string;
|
|
|
|
if (times === 1) {
|
2023-03-30 00:03:25 +00:00
|
|
|
firstMessage = i18n('icu:GroupV2--admin-approval-bounce--one', {
|
2023-08-16 20:54:39 +00:00
|
|
|
joinerName: renderContact(aci),
|
2022-03-16 00:11:28 +00:00
|
|
|
});
|
|
|
|
} else {
|
2023-03-30 00:03:25 +00:00
|
|
|
firstMessage = i18n('icu:GroupV2--admin-approval-bounce', {
|
2023-08-16 20:54:39 +00:00
|
|
|
joinerName: renderContact(aci),
|
2023-04-03 19:03:00 +00:00
|
|
|
numberOfRequests: times,
|
2022-03-16 00:11:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isApprovalPending) {
|
|
|
|
return firstMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
const secondMessage = renderChangeDetail(
|
|
|
|
{
|
|
|
|
type: 'admin-approval-add-one',
|
2023-08-16 20:54:39 +00:00
|
|
|
aci,
|
2022-03-16 00:11:28 +00:00
|
|
|
},
|
|
|
|
options
|
|
|
|
);
|
|
|
|
|
|
|
|
return [
|
|
|
|
firstMessage,
|
|
|
|
...(Array.isArray(secondMessage) ? secondMessage : [secondMessage]),
|
|
|
|
];
|
|
|
|
}
|
2020-12-18 19:27:43 +00:00
|
|
|
if (detail.type === 'group-link-add') {
|
|
|
|
const { privilege } = detail;
|
|
|
|
|
|
|
|
if (privilege === AccessControlEnum.ADMINISTRATOR) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-add--enabled--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-add--enabled--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-add--enabled--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (privilege === AccessControlEnum.ANY) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-add--disabled--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-add--disabled--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-add--disabled--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(`group-link-add change type, privilege ${privilege} is unknown`);
|
2020-12-18 19:27:43 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (detail.type === 'group-link-reset') {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-reset--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-reset--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-reset--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (detail.type === 'group-link-remove') {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-remove--you');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-remove--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
adminName: renderContact(from),
|
|
|
|
});
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--group-link-remove--unknown');
|
2020-12-18 19:27:43 +00:00
|
|
|
}
|
2021-06-02 00:24:28 +00:00
|
|
|
if (detail.type === 'description') {
|
|
|
|
if (detail.removed) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--description--remove--you');
|
2021-06-02 00:24:28 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--description--remove--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2021-06-02 00:24:28 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--description--remove--unknown');
|
2021-06-02 00:24:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--description--change--you');
|
2021-06-02 00:24:28 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--description--change--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2021-06-02 00:24:28 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--description--change--unknown');
|
2021-06-02 00:24:28 +00:00
|
|
|
}
|
2021-07-20 20:18:35 +00:00
|
|
|
if (detail.type === 'announcements-only') {
|
|
|
|
if (detail.announcementsOnly) {
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--announcements--admin--you');
|
2021-07-20 20:18:35 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--announcements--admin--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2021-07-20 20:18:35 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--announcements--admin--unknown');
|
2021-07-20 20:18:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fromYou) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--announcements--member--you');
|
2021-07-20 20:18:35 +00:00
|
|
|
}
|
|
|
|
if (from) {
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--announcements--member--other', {
|
2023-03-27 23:37:39 +00:00
|
|
|
memberName: renderContact(from),
|
|
|
|
});
|
2021-07-20 20:18:35 +00:00
|
|
|
}
|
2023-03-30 00:03:25 +00:00
|
|
|
return i18n('icu:GroupV2--announcements--member--unknown');
|
2021-07-20 20:18:35 +00:00
|
|
|
}
|
2022-12-06 21:12:57 +00:00
|
|
|
if (detail.type === 'summary') {
|
2023-03-29 17:15:54 +00:00
|
|
|
return i18n('icu:GroupV2--summary');
|
2022-12-06 21:12:57 +00:00
|
|
|
}
|
2020-12-18 19:27:43 +00:00
|
|
|
|
|
|
|
throw missingCaseError(detail);
|
2020-09-09 02:25:05 +00:00
|
|
|
}
|