@@ -122,6 +122,8 @@ async function sendReactionNotification({
122122 columns : [ "id" , "name" , "username" ] ,
123123 } ) ;
124124
125+ if ( ! actor ) return ;
126+
125127 if ( resourceType === "ARTICLE" ) {
126128 const [ article ] = await persistenceRepository . article . find ( {
127129 where : eq ( "id" , resourceId ) ,
@@ -133,6 +135,14 @@ async function sendReactionNotification({
133135 payload . article_id = article . id ;
134136 payload . article_handle = article . handle ;
135137 payload . article_title = article . title ;
138+ const [ articleAuthor ] = await persistenceRepository . user . find ( {
139+ where : eq ( "id" , article . author_id ) ,
140+ limit : 1 ,
141+ columns : [ "id" , "username" ] ,
142+ } ) ;
143+ if ( articleAuthor ?. username ) {
144+ payload . article_author_username = articleAuthor . username ;
145+ }
136146 }
137147 } else if ( resourceType === "COMMENT" ) {
138148 const [ comment ] = await persistenceRepository . comment . find ( {
@@ -159,8 +169,8 @@ async function sendReactionNotification({
159169 : "REACTION_ON_COMMENT" ,
160170 payload : {
161171 ...payload ,
162- actor_name : actor ? .name ,
163- actor_username : actor ? .username ,
172+ actor_name : actor . name ,
173+ actor_username : actor . username ,
164174 } ,
165175 } ,
166176 } ) ;
0 commit comments