@@ -59,8 +59,8 @@ class MessageReactionService {
59
59
60
60
const createdMessageReaction = await this . messageReactionRepository . save ( newMessageReaction ) ;
61
61
const customMessageReaction = this . customMessageReaction ( createdMessageReaction ) ;
62
- const displayNames = await this . addAuthorMessageReaction ( customMessageReaction ) ;
63
- return { ...customMessageReaction , displayNames } ;
62
+ const authors = await this . addAuthorMessageReaction ( customMessageReaction ) ;
63
+ return { ...customMessageReaction , authors } ;
64
64
}
65
65
66
66
customMessageReaction ( messageReaction ) {
@@ -78,11 +78,12 @@ class MessageReactionService {
78
78
. addSelect ( 'user' )
79
79
. where ( 'messageReaction.reactionId = :reactionId' , { reactionId } )
80
80
. getMany ( ) ;
81
- const displayNames = AuthorMessageReaction . map ( ( MessageReaction ) => {
82
- const { displayName } = MessageReaction . user ;
83
- return displayName ;
81
+ const author = AuthorMessageReaction . map ( ( MessageReaction ) => {
82
+ const { displayName, userId } = MessageReaction . user ;
83
+ return { displayName, userId } ;
84
84
} ) ;
85
- return displayNames ;
85
+
86
+ return author ;
86
87
}
87
88
88
89
async deleteMessageReaction ( userId : number , messageId : number , reactionId : number ) {
@@ -99,6 +100,23 @@ class MessageReactionService {
99
100
100
101
await this . messageReactionRepository . softDelete ( messageReaction . messageReactionId ) ;
101
102
}
103
+
104
+ async getMessageReaction ( messageId : number , reactionId : number ) {
105
+ const messageReactions = await this . messageReactionRepository
106
+ . createQueryBuilder ( 'messageReaction' )
107
+ . leftJoin ( 'messageReaction.user' , 'user' )
108
+ . select ( 'messageReaction' )
109
+ . addSelect ( 'user' )
110
+ . where ( 'messageReaction.messageId = :messageId' , { messageId } )
111
+ . andWhere ( 'messageReaction.reactionId = :reactionId' , { reactionId } )
112
+ . getMany ( ) ;
113
+ const authors = messageReactions . map ( ( messageReaction ) => {
114
+ const { userId, displayName } = messageReaction . user ;
115
+ return { userId, displayName } ;
116
+ } ) ;
117
+ const { title, emoji } = await this . reactionRepository . findOne ( { reactionId } ) ;
118
+ return { reactionId, title, emoji, messageId, authors } ;
119
+ }
102
120
}
103
121
104
122
export default MessageReactionService ;
0 commit comments