| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { LocalizerType } from './types/Util'; | 
					
						
							|  |  |  | import type { ReplacementValuesType } from './types/I18N'; | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  | import type { UUIDStringType } from './types/UUID'; | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | import { missingCaseError } from './util/missingCaseError'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { GroupV2ChangeDetailType, GroupV2ChangeType } from './groups'; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | import { SignalService as Proto } from './protobuf'; | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  | import * as log from './logging/log'; | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-16 09:44:54 -08:00
										 |  |  | export type SmartContactRendererType<T> = (uuid: UUIDStringType) => T | string; | 
					
						
							|  |  |  | export type StringRendererType<T> = ( | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |   id: string, | 
					
						
							|  |  |  |   i18n: LocalizerType, | 
					
						
							| 
									
										
										
										
											2021-12-16 09:44:54 -08:00
										 |  |  |   components?: Array<T | string> | ReplacementValuesType<T | string> | 
					
						
							|  |  |  | ) => T | string; | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-16 09:44:54 -08:00
										 |  |  | export type RenderOptionsType<T> = { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |   from?: UUIDStringType; | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |   i18n: LocalizerType; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |   ourACI?: UUIDStringType; | 
					
						
							|  |  |  |   ourPNI?: UUIDStringType; | 
					
						
							| 
									
										
										
										
											2021-12-16 09:44:54 -08:00
										 |  |  |   renderContact: SmartContactRendererType<T>; | 
					
						
							|  |  |  |   renderString: StringRendererType<T>; | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | const AccessControlEnum = Proto.AccessControl.AccessRequired; | 
					
						
							|  |  |  | const RoleEnum = Proto.Member.Role; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-15 17:11:28 -07: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 09:44:54 -08:00
										 |  |  | export function renderChange<T>( | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |   change: GroupV2ChangeType, | 
					
						
							| 
									
										
										
										
											2021-12-16 09:44:54 -08:00
										 |  |  |   options: RenderOptionsType<T> | 
					
						
							| 
									
										
										
										
											2022-03-15 17:11:28 -07:00
										 |  |  | ): RenderChangeResultType<T> { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |   const { details, from } = change; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-15 17:11:28 -07:00
										 |  |  |   return details.flatMap((detail: GroupV2ChangeDetailType) => { | 
					
						
							|  |  |  |     const texts = renderChangeDetail<T>(detail, { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       ...options, | 
					
						
							|  |  |  |       from, | 
					
						
							| 
									
										
										
										
											2022-03-15 17:11:28 -07: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-08 19:25:05 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-16 09:44:54 -08:00
										 |  |  | export function renderChangeDetail<T>( | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |   detail: GroupV2ChangeDetailType, | 
					
						
							| 
									
										
										
										
											2021-12-16 09:44:54 -08:00
										 |  |  |   options: RenderOptionsType<T> | 
					
						
							| 
									
										
										
										
											2022-03-15 17:11:28 -07:00
										 |  |  | ): T | string | ReadonlyArray<T | string> { | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |   const { from, i18n, ourACI, ourPNI, renderContact, renderString } = options; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const isOurUuid = (uuid?: UUIDStringType): boolean => { | 
					
						
							|  |  |  |     if (!uuid) { | 
					
						
							|  |  |  |       return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return Boolean((ourACI && uuid === ourACI) || (ourPNI && uuid === ourPNI)); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   const fromYou = isOurUuid(from); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |   if (detail.type === 'create') { | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--create--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--create--other', i18n, { | 
					
						
							|  |  |  |         memberName: renderContact(from), | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--create--unknown', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |   if (detail.type === 'title') { | 
					
						
							|  |  |  |     const { newTitle } = detail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (newTitle) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--title--change--you', i18n, [newTitle]); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--title--change--other', i18n, { | 
					
						
							|  |  |  |           memberName: renderContact(from), | 
					
						
							|  |  |  |           newTitle, | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--title--change--unknown', i18n, [newTitle]); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--title--remove--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--title--remove--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--title--remove--unknown', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'avatar') { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     if (detail.removed) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--avatar--remove--you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString('GroupV2--avatar--remove--other', i18n, [ | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--avatar--remove--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--avatar--change--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--avatar--change--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     return renderString('GroupV2--avatar--change--unknown', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'access-attributes') { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     const { newPrivilege } = detail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (newPrivilege === AccessControlEnum.ADMINISTRATOR) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--access-attributes--admins--you', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--access-attributes--admins--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--access-attributes--admins--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (newPrivilege === AccessControlEnum.MEMBER) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--access-attributes--all--you', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--access-attributes--all--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--access-attributes--all--unknown', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |     log.warn( | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       `access-attributes change type, privilege ${newPrivilege} is unknown` | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     return ''; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'access-members') { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     const { newPrivilege } = detail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (newPrivilege === AccessControlEnum.ADMINISTRATOR) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--access-members--admins--you', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--access-members--admins--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--access-members--admins--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (newPrivilege === AccessControlEnum.MEMBER) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--access-members--all--you', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--access-members--all--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--access-members--all--unknown', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |     log.warn( | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       `access-members change type, privilege ${newPrivilege} is unknown` | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     return ''; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'access-invite-link') { | 
					
						
							|  |  |  |     const { newPrivilege } = detail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (newPrivilege === AccessControlEnum.ADMINISTRATOR) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--access-invite-link--enabled--you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--access-invite-link--enabled--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           [renderContact(from)] | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--access-invite-link--enabled--unknown', | 
					
						
							|  |  |  |         i18n | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (newPrivilege === AccessControlEnum.ANY) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--access-invite-link--disabled--you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--access-invite-link--disabled--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           [renderContact(from)] | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--access-invite-link--disabled--unknown', | 
					
						
							|  |  |  |         i18n | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |     log.warn( | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |       `access-invite-link change type, privilege ${newPrivilege} is unknown` | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     return ''; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'member-add') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreJoiner = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (weAreJoiner) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--member-add--you--you', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--member-add--you--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--member-add--you--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--member-add--other--you', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--member-add--other--other', i18n, { | 
					
						
							|  |  |  |         adderName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         addeeName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     return renderString('GroupV2--member-add--other--unknown', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |       renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     ]); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'member-add-from-invite') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid, inviter } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreJoiner = isOurUuid(uuid); | 
					
						
							|  |  |  |     const weAreInviter = isOurUuid(inviter); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-10 17:20:13 -08:00
										 |  |  |     if (!from || from !== uuid) { | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |       if (weAreJoiner) { | 
					
						
							|  |  |  |         // They can't be the same, no fromYou check here
 | 
					
						
							|  |  |  |         if (from) { | 
					
						
							|  |  |  |           return renderString('GroupV2--member-add--you--other', i18n, [ | 
					
						
							|  |  |  |             renderContact(from), | 
					
						
							|  |  |  |           ]); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return renderString('GroupV2--member-add--you--unknown', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--member-add--invited--you', i18n, { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           inviteeName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString('GroupV2--member-add--invited--other', i18n, { | 
					
						
							|  |  |  |           memberName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           inviteeName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString('GroupV2--member-add--invited--unknown', i18n, { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         inviteeName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     if (weAreJoiner) { | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |       if (inviter) { | 
					
						
							|  |  |  |         return renderString('GroupV2--member-add--from-invite--you', i18n, [ | 
					
						
							|  |  |  |           renderContact(inviter), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--member-add--from-invite--you-no-from', | 
					
						
							|  |  |  |         i18n | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (weAreInviter) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       return renderString('GroupV2--member-add--from-invite--from-you', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |     if (inviter) { | 
					
						
							|  |  |  |       return renderString('GroupV2--member-add--from-invite--other', i18n, { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         inviteeName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |         inviterName: renderContact(inviter), | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString( | 
					
						
							|  |  |  |       'GroupV2--member-add--from-invite--other-no-from', | 
					
						
							|  |  |  |       i18n, | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         inviteeName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-28 10:22:57 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'member-add-from-link') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid } = detail; | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     if (fromYou && isOurUuid(uuid)) { | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |       return renderString('GroupV2--member-add-from-link--you--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     if (from && uuid === from) { | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |       return renderString('GroupV2--member-add-from-link--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // 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 14:27:53 -04:00
										 |  |  |     log.warn('member-add-from-link change type; we have no from!'); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     return renderString('GroupV2--member-add--other--unknown', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |       renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     ]); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'member-add-from-admin-approval') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreJoiner = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (weAreJoiner) { | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--member-add-from-admin-approval--you--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           [renderContact(from)] | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // 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 14:27:53 -04:00
										 |  |  |       log.warn( | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |         '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 | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--member-add-from-admin-approval--other--you', | 
					
						
							|  |  |  |         i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--member-add-from-admin-approval--other--other', | 
					
						
							|  |  |  |         i18n, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           adminName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           joinerName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08: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 14:27:53 -04:00
										 |  |  |     log.warn('member-add-from-admin-approval change type; we have no from'); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     return renderString( | 
					
						
							|  |  |  |       'GroupV2--member-add-from-admin-approval--other--unknown', | 
					
						
							|  |  |  |       i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |       [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'member-remove') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreLeaver = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (weAreLeaver) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--member-remove--you--you', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--member-remove--you--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--member-remove--you--unknown', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--member-remove--other--you', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     if (from && from === uuid) { | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--member-remove--other--self', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--member-remove--other--other', i18n, { | 
					
						
							|  |  |  |         adminName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         memberName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--member-remove--other--unknown', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |       renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     ]); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'member-privilege') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid, newPrivilege } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreMember = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (newPrivilege === RoleEnum.ADMINISTRATOR) { | 
					
						
							|  |  |  |       if (weAreMember) { | 
					
						
							|  |  |  |         if (from) { | 
					
						
							|  |  |  |           return renderString( | 
					
						
							|  |  |  |             'GroupV2--member-privilege--promote--you--other', | 
					
						
							|  |  |  |             i18n, | 
					
						
							|  |  |  |             [renderContact(from)] | 
					
						
							|  |  |  |           ); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--member-privilege--promote--you--unknown', | 
					
						
							|  |  |  |           i18n | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--member-privilege--promote--other--you', | 
					
						
							|  |  |  |           i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--member-privilege--promote--other--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             adminName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |             memberName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |           } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--member-privilege--promote--other--unknown', | 
					
						
							|  |  |  |         i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (newPrivilege === RoleEnum.DEFAULT) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       if (weAreMember) { | 
					
						
							|  |  |  |         if (from) { | 
					
						
							|  |  |  |           return renderString( | 
					
						
							|  |  |  |             'GroupV2--member-privilege--demote--you--other', | 
					
						
							|  |  |  |             i18n, | 
					
						
							|  |  |  |             [renderContact(from)] | 
					
						
							|  |  |  |           ); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--member-privilege--demote--you--unknown', | 
					
						
							|  |  |  |           i18n | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--member-privilege--demote--other--you', | 
					
						
							|  |  |  |           i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--member-privilege--demote--other--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             adminName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |             memberName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |           } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--member-privilege--demote--other--unknown', | 
					
						
							|  |  |  |         i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |     log.warn( | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       `member-privilege change type, privilege ${newPrivilege} is unknown` | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     return ''; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'pending-add-one') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreInvited = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     if (weAreInvited) { | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString('GroupV2--pending-add--one--you--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--pending-add--one--you--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--pending-add--one--other--you', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       ]); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--pending-add--one--other--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--pending-add--one--other--unknown', i18n); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'pending-add-many') { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     const { count } = detail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--pending-add--many--you', i18n, [ | 
					
						
							|  |  |  |         count.toString(), | 
					
						
							|  |  |  |       ]); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       return renderString('GroupV2--pending-add--many--other', i18n, { | 
					
						
							|  |  |  |         memberName: renderContact(from), | 
					
						
							|  |  |  |         count: count.toString(), | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     return renderString('GroupV2--pending-add--many--unknown', i18n, [ | 
					
						
							|  |  |  |       count.toString(), | 
					
						
							|  |  |  |     ]); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'pending-remove-one') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { inviter, uuid } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreInviter = isOurUuid(inviter); | 
					
						
							|  |  |  |     const weAreInvited = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const sentByInvited = Boolean(from && from === uuid); | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |     const sentByInviter = Boolean(from && inviter && from === inviter); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (weAreInviter) { | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |       if (sentByInvited) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString('GroupV2--pending-remove--decline--you', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         ]); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from-you--one--you', | 
					
						
							|  |  |  |           i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from-you--one--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             adminName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |             inviteeName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |           } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--pending-remove--revoke-invite-from-you--one--unknown', | 
					
						
							|  |  |  |         i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (sentByInvited) { | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--pending-remove--decline--from-you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       if (inviter) { | 
					
						
							|  |  |  |         return renderString('GroupV2--pending-remove--decline--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(inviter), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString('GroupV2--pending-remove--decline--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |     if (inviter && sentByInviter) { | 
					
						
							|  |  |  |       if (weAreInvited) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-own--to-you', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           [renderContact(inviter)] | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--pending-remove--revoke-own--unknown', | 
					
						
							|  |  |  |         i18n, | 
					
						
							|  |  |  |         [renderContact(inviter)] | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     if (inviter) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from--one--you', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           [renderContact(inviter)] | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from--one--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             adminName: renderContact(from), | 
					
						
							|  |  |  |             memberName: renderContact(inviter), | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--pending-remove--revoke-invite-from--one--unknown', | 
					
						
							|  |  |  |         i18n, | 
					
						
							|  |  |  |         [renderContact(inviter)] | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--pending-remove--revoke--one--you', i18n); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--pending-remove--revoke--one--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--pending-remove--revoke--one--unknown', i18n); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'pending-remove-many') { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     const { count, inviter } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreInviter = isOurUuid(inviter); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (weAreInviter) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from-you--many--you', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           [count.toString()] | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from-you--many--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             adminName: renderContact(from), | 
					
						
							|  |  |  |             count: count.toString(), | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--pending-remove--revoke-invite-from-you--many--unknown', | 
					
						
							|  |  |  |         i18n, | 
					
						
							|  |  |  |         [count.toString()] | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (inviter) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from--many--you', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             count: count.toString(), | 
					
						
							|  |  |  |             memberName: renderContact(inviter), | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--pending-remove--revoke-invite-from--many--other', | 
					
						
							|  |  |  |           i18n, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             adminName: renderContact(from), | 
					
						
							|  |  |  |             count: count.toString(), | 
					
						
							|  |  |  |             memberName: renderContact(inviter), | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--pending-remove--revoke-invite-from--many--unknown', | 
					
						
							|  |  |  |         i18n, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           count: count.toString(), | 
					
						
							|  |  |  |           memberName: renderContact(inviter), | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--pending-remove--revoke--many--you', i18n, [ | 
					
						
							|  |  |  |         count.toString(), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--pending-remove--revoke--many--other', | 
					
						
							|  |  |  |         i18n, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           memberName: renderContact(from), | 
					
						
							|  |  |  |           count: count.toString(), | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-11 12:37:01 -07:00
										 |  |  |     return renderString( | 
					
						
							|  |  |  |       'GroupV2--pending-remove--revoke--many--unknown', | 
					
						
							|  |  |  |       i18n, | 
					
						
							|  |  |  |       [count.toString()] | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   if (detail.type === 'admin-approval-add-one') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreJoiner = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (weAreJoiner) { | 
					
						
							|  |  |  |       return renderString('GroupV2--admin-approval-add-one--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--admin-approval-add-one--other', i18n, [ | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |       renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     ]); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'admin-approval-remove-one') { | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     const { uuid } = detail; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |     const weAreJoiner = isOurUuid(uuid); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (weAreJoiner) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString( | 
					
						
							|  |  |  |           'GroupV2--admin-approval-remove-one--you--you', | 
					
						
							|  |  |  |           i18n | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--admin-approval-remove-one--you--unknown', | 
					
						
							|  |  |  |         i18n | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--admin-approval-remove-one--other--you', | 
					
						
							|  |  |  |         i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |     if (from && from === uuid) { | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--admin-approval-remove-one--other--own', | 
					
						
							|  |  |  |         i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |         [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString( | 
					
						
							|  |  |  |         'GroupV2--admin-approval-remove-one--other--other', | 
					
						
							|  |  |  |         i18n, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           adminName: renderContact(from), | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |           joinerName: renderContact(uuid), | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08: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.
 | 
					
						
							|  |  |  |     return renderString( | 
					
						
							|  |  |  |       'GroupV2--admin-approval-remove-one--other--own', | 
					
						
							|  |  |  |       i18n, | 
					
						
							| 
									
										
										
										
											2021-10-26 15:59:08 -07:00
										 |  |  |       [renderContact(uuid)] | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-03-15 17:11:28 -07:00
										 |  |  |   if (detail.type === 'admin-approval-bounce') { | 
					
						
							|  |  |  |     const { uuid, times, isApprovalPending } = detail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let firstMessage: T | string; | 
					
						
							|  |  |  |     if (times === 1) { | 
					
						
							|  |  |  |       firstMessage = renderString('GroupV2--admin-approval-bounce--one', i18n, { | 
					
						
							|  |  |  |         joinerName: renderContact(uuid), | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       firstMessage = renderString('GroupV2--admin-approval-bounce', i18n, { | 
					
						
							|  |  |  |         joinerName: renderContact(uuid), | 
					
						
							|  |  |  |         numberOfRequests: String(times), | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!isApprovalPending) { | 
					
						
							|  |  |  |       return firstMessage; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const secondMessage = renderChangeDetail( | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         type: 'admin-approval-add-one', | 
					
						
							|  |  |  |         uuid, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       options | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return [ | 
					
						
							|  |  |  |       firstMessage, | 
					
						
							|  |  |  |       ...(Array.isArray(secondMessage) ? secondMessage : [secondMessage]), | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |   if (detail.type === 'group-link-add') { | 
					
						
							|  |  |  |     const { privilege } = detail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (privilege === AccessControlEnum.ADMINISTRATOR) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--group-link-add--enabled--you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString('GroupV2--group-link-add--enabled--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString('GroupV2--group-link-add--enabled--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (privilege === AccessControlEnum.ANY) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--group-link-add--disabled--you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString('GroupV2--group-link-add--disabled--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString('GroupV2--group-link-add--disabled--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |     log.warn(`group-link-add change type, privilege ${privilege} is unknown`); | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  |     return ''; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'group-link-reset') { | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--group-link-reset--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--group-link-reset--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--group-link-reset--unknown', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (detail.type === 'group-link-remove') { | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--group-link-remove--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--group-link-remove--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--group-link-remove--unknown', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-06-01 17:24:28 -07:00
										 |  |  |   if (detail.type === 'description') { | 
					
						
							|  |  |  |     if (detail.removed) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--description--remove--you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString('GroupV2--description--remove--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString('GroupV2--description--remove--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--description--change--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--description--change--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--description--change--unknown', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-07-20 16:18:35 -04:00
										 |  |  |   if (detail.type === 'announcements-only') { | 
					
						
							|  |  |  |     if (detail.announcementsOnly) { | 
					
						
							|  |  |  |       if (fromYou) { | 
					
						
							|  |  |  |         return renderString('GroupV2--announcements--admin--you', i18n); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (from) { | 
					
						
							|  |  |  |         return renderString('GroupV2--announcements--admin--other', i18n, [ | 
					
						
							|  |  |  |           renderContact(from), | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return renderString('GroupV2--announcements--admin--unknown', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fromYou) { | 
					
						
							|  |  |  |       return renderString('GroupV2--announcements--member--you', i18n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (from) { | 
					
						
							|  |  |  |       return renderString('GroupV2--announcements--member--other', i18n, [ | 
					
						
							|  |  |  |         renderContact(from), | 
					
						
							|  |  |  |       ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return renderString('GroupV2--announcements--member--unknown', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-12-06 13:12:57 -08:00
										 |  |  |   if (detail.type === 'summary') { | 
					
						
							|  |  |  |     return renderString('icu:GroupV2--summary', i18n); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-12-18 11:27:43 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   throw missingCaseError(detail); | 
					
						
							| 
									
										
										
										
											2020-09-08 19:25:05 -07:00
										 |  |  | } |