@ -80,18 +80,20 @@ SocketHelpers.sendNotificationToPostOwner = async function (pid, fromuid, comman
if ( ! canRead || isIgnoring [ 0 ] || ! postData . uid || fromuid === postData . uid ) {
if ( ! canRead || isIgnoring [ 0 ] || ! postData . uid || fromuid === postData . uid ) {
return ;
return ;
}
}
const [ user name , topicTitle , postObj ] = await Promise . all ( [
const [ user Data , topicTitle , postObj ] = await Promise . all ( [
user . getUserField ( fromuid , 'username' ) ,
user . getUserField s ( fromuid , [ 'username' ] ) ,
topics . getTopicField ( postData . tid , 'title' ) ,
topics . getTopicField ( postData . tid , 'title' ) ,
posts . parsePost ( postData ) ,
posts . parsePost ( postData ) ,
] ) ;
] ) ;
const { displayname } = userData ;
const title = utils . decodeHTMLEntities ( topicTitle ) ;
const title = utils . decodeHTMLEntities ( topicTitle ) ;
const titleEscaped = title . replace ( /%/g , '%' ) . replace ( /,/g , ',' ) ;
const titleEscaped = title . replace ( /%/g , '%' ) . replace ( /,/g , ',' ) ;
const notifObj = await notifications . create ( {
const notifObj = await notifications . create ( {
type : command ,
type : command ,
bodyShort : ` [[ ${ notification } , ${ user name} , ${ titleEscaped } ]] ` ,
bodyShort : ` [[ ${ notification } , ${ display name} , ${ titleEscaped } ]] ` ,
bodyLong : postObj . content ,
bodyLong : postObj . content ,
pid : pid ,
pid : pid ,
tid : postData . tid ,
tid : postData . tid ,
@ -113,20 +115,23 @@ SocketHelpers.sendNotificationToTopicOwner = async function (tid, fromuid, comma
fromuid = parseInt ( fromuid , 10 ) ;
fromuid = parseInt ( fromuid , 10 ) ;
const [ user name , topicData ] = await Promise . all ( [
const [ user Data , topicData ] = await Promise . all ( [
user . getUserField ( fromuid , 'username' ) ,
user . getUserField s ( fromuid , [ 'username' ] ) ,
topics . getTopicFields ( tid , [ 'uid' , 'slug' , 'title' ] ) ,
topics . getTopicFields ( tid , [ 'uid' , 'slug' , 'title' ] ) ,
] ) ;
] ) ;
if ( fromuid === topicData . uid ) {
if ( fromuid === topicData . uid ) {
return ;
return ;
}
}
const { displayname } = userData ;
const ownerUid = topicData . uid ;
const ownerUid = topicData . uid ;
const title = utils . decodeHTMLEntities ( topicData . title ) ;
const title = utils . decodeHTMLEntities ( topicData . title ) ;
const titleEscaped = title . replace ( /%/g , '%' ) . replace ( /,/g , ',' ) ;
const titleEscaped = title . replace ( /%/g , '%' ) . replace ( /,/g , ',' ) ;
const notifObj = await notifications . create ( {
const notifObj = await notifications . create ( {
bodyShort : ` [[ ${ notification } , ${ user name} , ${ titleEscaped } ]] ` ,
bodyShort : ` [[ ${ notification } , ${ display name} , ${ titleEscaped } ]] ` ,
path : ` /topic/ ${ topicData . slug } ` ,
path : ` /topic/ ${ topicData . slug } ` ,
nid : ` ${ command } :tid: ${ tid } :uid: ${ fromuid } ` ,
nid : ` ${ command } :tid: ${ tid } :uid: ${ fromuid } ` ,
from : fromuid ,
from : fromuid ,