@@ -27,6 +27,8 @@ export default Component.extend(
2727 case notificationTypes . discussionReply :
2828 case notificationTypes . postAtMention :
2929 case notificationTypes . threadAtMention :
30+ case notificationTypes . messageWallPost :
31+ case notificationTypes . messageWallReply :
3032 return 'wds-icons-comment-small' ;
3133 case notificationTypes . announcement :
3234 return 'wds-icons-flag-small' ;
@@ -86,6 +88,12 @@ export default Component.extend(
8688 return this . getArticleCommentAtMentionMessageBody ( this . model ) ;
8789 case notificationTypes . articleCommentReplyAtMention :
8890 return this . getArticleCommentReplyAtMentionMessageBody ( this . model ) ;
91+ case notificationTypes . messageWallPost :
92+ return this . getMessageWallPostBody ( this . model ) ;
93+ case notificationTypes . messageWallReply :
94+ return this . getMessageWallReplyBody ( this . model ) ;
95+ case notificationTypes . messageWallPostRemoved :
96+ return this . getMessageWallPostRemovedBody ( this . model ) ;
8997 default :
9098 return null ;
9199 }
@@ -295,6 +303,98 @@ export default Component.extend(
295303 } ) ;
296304 } ,
297305
306+ getMessageWallPostBody ( model ) {
307+ let wallOwner = model . get ( 'metadata.wallOwnerName' ) ;
308+ const currentUsername = this . wdsOnSiteNotifications . currentUser . name ;
309+
310+ if ( ! wallOwner ) {
311+ wallOwner = this . getMessageWallOwner ( model . get ( 'uri' ) ) ;
312+ }
313+
314+ const isOwnWall = wallOwner === currentUsername ;
315+ const args = {
316+ postTitle : model . get ( 'title' ) ,
317+ wallOwner,
318+ } ;
319+
320+ if ( isOwnWall ) {
321+ args . user = this . getPossiblyAnonActorName ( model ) ;
322+ return this . getTranslatedMessage ( 'notifications-own-wall-post' , args ) ;
323+ }
324+
325+ args . firstUser = this . getPossiblyAnonActorName ( model ) ;
326+ return this . getTranslatedMessage ( 'notifications-wall-post' , args ) ;
327+ } ,
328+
329+ getMessageWallReplyBody ( model ) {
330+ let wallOwner = model . get ( 'metadata.wallOwnerName' ) ;
331+ const currentUsername = this . wdsOnSiteNotifications . currentUser . name ;
332+
333+ if ( ! wallOwner ) {
334+ wallOwner = this . getMessageWallOwner ( model . get ( 'uri' ) ) ;
335+ }
336+
337+ const isOwnWall = wallOwner === currentUsername ;
338+ const args = {
339+ postTitle : model . get ( 'title' ) ,
340+ wallOwner,
341+ } ;
342+
343+ if ( model . get ( 'totalUniqueActors' ) > 1 ) {
344+ args . number = model . get ( 'totalUniqueActors' ) - 1 ;
345+
346+ if ( isOwnWall ) {
347+ args . user = this . getPossiblyAnonActorName ( model ) ;
348+ return this . getTranslatedMessage ( 'notifications-own-wall-reply-multiple-users' , args ) ;
349+ }
350+
351+ args . firstUser = this . getPossiblyAnonActorName ( model ) ;
352+
353+ if ( model . get ( 'contentCreatorName' ) === currentUsername ) {
354+ return this . getTranslatedMessage ( 'notifications-wall-reply-multiple-users-own-message' , args ) ;
355+ }
356+
357+ args . secondUser = model . get ( 'contentCreatorName' ) || this . getTranslatedMessage ( 'username-anonymous' ) ;
358+ return this . getTranslatedMessage ( 'notifications-wall-reply-multiple-users' , args ) ;
359+ }
360+
361+ if ( isOwnWall ) {
362+ args . user = this . getPossiblyAnonActorName ( model ) ;
363+ return this . getTranslatedMessage ( 'notifications-own-wall-reply' , args ) ;
364+ }
365+
366+ if ( model . get ( 'contentCreatorName' ) === currentUsername ) {
367+ args . user = this . getPossiblyAnonActorName ( model ) ;
368+ return this . getTranslatedMessage ( 'notifications-wall-reply-own-message' , args ) ;
369+ }
370+
371+ args . firstUser = this . getPossiblyAnonActorName ( model ) ;
372+ args . secondUser = model . get ( 'contentCreatorName' ) || this . getTranslatedMessage ( 'username-anonymous' ) ;
373+
374+ return this . getTranslatedMessage ( 'notifications-wall-reply' , args ) ;
375+ } ,
376+
377+ getMessageWallPostRemovedBody ( model ) {
378+ return this . getTranslatedMessage ( 'notifications-own-wall-post-removed' , {
379+ postTitle : model . get ( 'title' ) ,
380+ } ) ;
381+ } ,
382+
383+ getMessageWallOwner ( url ) {
384+ const regex = / \/ M e s s a g e _ W a l l : ( .+ ?) ( [ ? # / ] .* ) ? $ / i;
385+ const result = regex . exec ( url ) ;
386+
387+ if ( ! result || ! result [ 1 ] ) {
388+ return null ;
389+ }
390+
391+ return result [ 1 ] ;
392+ } ,
393+
394+ getPossiblyAnonActorName ( model ) {
395+ return model . get ( 'latestActors.0.name' ) ? model . get ( 'latestActors.0.name' ) : this . getTranslatedMessage ( 'username-anonymous' ) ;
396+ } ,
397+
298398 getTranslatedMessage ( key , context ) {
299399 const fullContext = extend ( { } , {
300400 ns : 'design-system' ,
0 commit comments