@@ -41,7 +41,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
4141 // required: true
4242 // responses:
4343 // "200":
44- // "$ref": "#/responses/ReactionResponseList "
44+ // "$ref": "#/responses/ReactionList "
4545 // "403":
4646 // "$ref": "#/responses/forbidden"
4747
@@ -71,9 +71,9 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
7171 return
7272 }
7373
74- var result []api.ReactionResponse
74+ var result []api.Reaction
7575 for _ , r := range reactions {
76- result = append (result , api.ReactionResponse {
76+ result = append (result , api.Reaction {
7777 User : r .User .APIFormat (),
7878 Reaction : r .Type ,
7979 Created : r .CreatedUnix .AsTime (),
@@ -114,8 +114,10 @@ func PostIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOpti
114114 // schema:
115115 // "$ref": "#/definitions/EditReactionOption"
116116 // responses:
117+ // "200":
118+ // "$ref": "#/responses/Reaction"
117119 // "201":
118- // "$ref": "#/responses/ReactionResponse "
120+ // "$ref": "#/responses/Reaction "
119121 // "403":
120122 // "$ref": "#/responses/forbidden"
121123
@@ -188,19 +190,20 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp
188190 if err != nil {
189191 if models .IsErrForbiddenIssueReaction (err ) {
190192 ctx .Error (http .StatusForbidden , err .Error (), err )
193+ } else if models .IsErrReactionAlreadyExist (err ) {
194+ ctx .JSON (http .StatusOK , api.Reaction {
195+ User : ctx .User .APIFormat (),
196+ Reaction : reaction .Type ,
197+ Created : reaction .CreatedUnix .AsTime (),
198+ })
191199 } else {
192200 ctx .Error (http .StatusInternalServerError , "CreateCommentReaction" , err )
193201 }
194202 return
195203 }
196- _ , err = reaction .LoadUser ()
197- if err != nil {
198- ctx .Error (http .StatusInternalServerError , "Reaction.LoadUser()" , err )
199- return
200- }
201204
202- ctx .JSON (http .StatusCreated , api.ReactionResponse {
203- User : reaction .User .APIFormat (),
205+ ctx .JSON (http .StatusCreated , api.Reaction {
206+ User : ctx .User .APIFormat (),
204207 Reaction : reaction .Type ,
205208 Created : reaction .CreatedUnix .AsTime (),
206209 })
@@ -244,7 +247,7 @@ func GetIssueReactions(ctx *context.APIContext) {
244247 // required: true
245248 // responses:
246249 // "200":
247- // "$ref": "#/responses/ReactionResponseList "
250+ // "$ref": "#/responses/ReactionList "
248251 // "403":
249252 // "$ref": "#/responses/forbidden"
250253
@@ -274,9 +277,9 @@ func GetIssueReactions(ctx *context.APIContext) {
274277 return
275278 }
276279
277- var result []api.ReactionResponse
280+ var result []api.Reaction
278281 for _ , r := range reactions {
279- result = append (result , api.ReactionResponse {
282+ result = append (result , api.Reaction {
280283 User : r .User .APIFormat (),
281284 Reaction : r .Type ,
282285 Created : r .CreatedUnix .AsTime (),
@@ -317,8 +320,10 @@ func PostIssueReaction(ctx *context.APIContext, form api.EditReactionOption) {
317320 // schema:
318321 // "$ref": "#/definitions/EditReactionOption"
319322 // responses:
323+ // "200":
324+ // "$ref": "#/responses/Reaction"
320325 // "201":
321- // "$ref": "#/responses/ReactionResponse "
326+ // "$ref": "#/responses/Reaction "
322327 // "403":
323328 // "$ref": "#/responses/forbidden"
324329
@@ -386,19 +391,20 @@ func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, i
386391 if err != nil {
387392 if models .IsErrForbiddenIssueReaction (err ) {
388393 ctx .Error (http .StatusForbidden , err .Error (), err )
394+ } else if models .IsErrReactionAlreadyExist (err ) {
395+ ctx .JSON (http .StatusOK , api.Reaction {
396+ User : ctx .User .APIFormat (),
397+ Reaction : reaction .Type ,
398+ Created : reaction .CreatedUnix .AsTime (),
399+ })
389400 } else {
390401 ctx .Error (http .StatusInternalServerError , "CreateCommentReaction" , err )
391402 }
392403 return
393404 }
394- _ , err = reaction .LoadUser ()
395- if err != nil {
396- ctx .Error (http .StatusInternalServerError , "Reaction.LoadUser()" , err )
397- return
398- }
399405
400- ctx .JSON (http .StatusCreated , api.ReactionResponse {
401- User : reaction .User .APIFormat (),
406+ ctx .JSON (http .StatusCreated , api.Reaction {
407+ User : ctx .User .APIFormat (),
402408 Reaction : reaction .Type ,
403409 Created : reaction .CreatedUnix .AsTime (),
404410 })
0 commit comments