@@ -15,6 +15,7 @@ import * as IOU from './actions/IOU';
15
15
import * as CurrencyUtils from './CurrencyUtils' ;
16
16
import DateUtils from './DateUtils' ;
17
17
import isReportMessageAttachment from './isReportMessageAttachment' ;
18
+ import * as LocalePhoneNumber from './LocalePhoneNumber' ;
18
19
import * as Localize from './Localize' ;
19
20
import linkingConfig from './Navigation/linkingConfig' ;
20
21
import Navigation from './Navigation/Navigation' ;
@@ -4144,6 +4145,48 @@ function getIOUReportActionDisplayMessage(reportAction) {
4144
4145
} ) ;
4145
4146
}
4146
4147
4148
+ /**
4149
+ * Return room channel log display message
4150
+ *
4151
+ * @param {Object } reportAction
4152
+ * @returns {String }
4153
+ */
4154
+ function getChannelLogMemberMessage ( reportAction ) {
4155
+ const verb =
4156
+ reportAction . actionName === CONST . REPORT . ACTIONS . TYPE . ROOMCHANGELOG . INVITE_TO_ROOM || reportAction . actionName === CONST . REPORT . ACTIONS . TYPE . POLICYCHANGELOG . INVITE_TO_ROOM
4157
+ ? 'invited'
4158
+ : 'removed' ;
4159
+
4160
+ const mentions = _ . map ( reportAction . originalMessage . targetAccountIDs , ( accountID ) => {
4161
+ const personalDetail = lodashGet ( allPersonalDetails , accountID ) ;
4162
+ const displayNameOrLogin =
4163
+ LocalePhoneNumber . formatPhoneNumber ( lodashGet ( personalDetail , 'login' , '' ) ) || lodashGet ( personalDetail , 'displayName' , '' ) || Localize . translateLocal ( 'common.hidden' ) ;
4164
+ return `@${ displayNameOrLogin } ` ;
4165
+ } ) ;
4166
+
4167
+ const lastMention = mentions . pop ( ) ;
4168
+ let message = '' ;
4169
+
4170
+ if ( mentions . length === 0 ) {
4171
+ message = `${ verb } ${ lastMention } ` ;
4172
+ } else if ( mentions . length === 1 ) {
4173
+ message = `${ verb } ${ mentions [ 0 ] } and ${ lastMention } ` ;
4174
+ } else {
4175
+ message = `${ verb } ${ mentions . join ( ', ' ) } , and ${ lastMention } ` ;
4176
+ }
4177
+
4178
+ const roomName = lodashGet ( reportAction , 'originalMessage.roomName' , '' ) ;
4179
+ if ( roomName ) {
4180
+ const preposition =
4181
+ reportAction . actionName === CONST . REPORT . ACTIONS . TYPE . ROOMCHANGELOG . INVITE_TO_ROOM || reportAction . actionName === CONST . REPORT . ACTIONS . TYPE . POLICYCHANGELOG . INVITE_TO_ROOM
4182
+ ? ' to'
4183
+ : ' from' ;
4184
+ message += `${ preposition } ${ roomName } ` ;
4185
+ }
4186
+
4187
+ return message ;
4188
+ }
4189
+
4147
4190
/**
4148
4191
* Checks if a report is a group chat.
4149
4192
*
@@ -4366,6 +4409,7 @@ export {
4366
4409
parseReportRouteParams ,
4367
4410
getReimbursementQueuedActionMessage ,
4368
4411
getPersonalDetailsForAccountID ,
4412
+ getChannelLogMemberMessage ,
4369
4413
getRoom ,
4370
4414
shouldDisableWelcomeMessage ,
4371
4415
} ;
0 commit comments