|
|
@ -41,7 +41,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) { |
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
// "200":
|
|
|
|
// "200":
|
|
|
|
// "$ref": "#/responses/ReactionResponseList"
|
|
|
|
// "$ref": "#/responses/ReactionList"
|
|
|
|
// "403":
|
|
|
|
// "403":
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
|
|
|
|
|
|
|
@ -71,9 +71,9 @@ func GetIssueCommentReactions(ctx *context.APIContext) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var result []api.ReactionResponse |
|
|
|
var result []api.Reaction |
|
|
|
for _, r := range reactions { |
|
|
|
for _, r := range reactions { |
|
|
|
result = append(result, api.ReactionResponse{ |
|
|
|
result = append(result, api.Reaction{ |
|
|
|
User: r.User.APIFormat(), |
|
|
|
User: r.User.APIFormat(), |
|
|
|
Reaction: r.Type, |
|
|
|
Reaction: r.Type, |
|
|
|
Created: r.CreatedUnix.AsTime(), |
|
|
|
Created: r.CreatedUnix.AsTime(), |
|
|
@ -114,8 +114,10 @@ func PostIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOpti |
|
|
|
// schema:
|
|
|
|
// schema:
|
|
|
|
// "$ref": "#/definitions/EditReactionOption"
|
|
|
|
// "$ref": "#/definitions/EditReactionOption"
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
|
|
|
|
// "200":
|
|
|
|
|
|
|
|
// "$ref": "#/responses/Reaction"
|
|
|
|
// "201":
|
|
|
|
// "201":
|
|
|
|
// "$ref": "#/responses/ReactionResponse"
|
|
|
|
// "$ref": "#/responses/Reaction"
|
|
|
|
// "403":
|
|
|
|
// "403":
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
|
|
|
|
|
|
|
@ -188,19 +190,20 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if models.IsErrForbiddenIssueReaction(err) { |
|
|
|
if models.IsErrForbiddenIssueReaction(err) { |
|
|
|
ctx.Error(http.StatusForbidden, err.Error(), err) |
|
|
|
ctx.Error(http.StatusForbidden, err.Error(), err) |
|
|
|
|
|
|
|
} else if models.IsErrReactionAlreadyExist(err) { |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, api.Reaction{ |
|
|
|
|
|
|
|
User: ctx.User.APIFormat(), |
|
|
|
|
|
|
|
Reaction: reaction.Type, |
|
|
|
|
|
|
|
Created: reaction.CreatedUnix.AsTime(), |
|
|
|
|
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.Error(http.StatusInternalServerError, "CreateCommentReaction", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "CreateCommentReaction", err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
_, err = reaction.LoadUser() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "Reaction.LoadUser()", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.JSON(http.StatusCreated, api.ReactionResponse{ |
|
|
|
ctx.JSON(http.StatusCreated, api.Reaction{ |
|
|
|
User: reaction.User.APIFormat(), |
|
|
|
User: ctx.User.APIFormat(), |
|
|
|
Reaction: reaction.Type, |
|
|
|
Reaction: reaction.Type, |
|
|
|
Created: reaction.CreatedUnix.AsTime(), |
|
|
|
Created: reaction.CreatedUnix.AsTime(), |
|
|
|
}) |
|
|
|
}) |
|
|
@ -244,7 +247,7 @@ func GetIssueReactions(ctx *context.APIContext) { |
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
// "200":
|
|
|
|
// "200":
|
|
|
|
// "$ref": "#/responses/ReactionResponseList"
|
|
|
|
// "$ref": "#/responses/ReactionList"
|
|
|
|
// "403":
|
|
|
|
// "403":
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
|
|
|
|
|
|
|
@ -274,9 +277,9 @@ func GetIssueReactions(ctx *context.APIContext) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var result []api.ReactionResponse |
|
|
|
var result []api.Reaction |
|
|
|
for _, r := range reactions { |
|
|
|
for _, r := range reactions { |
|
|
|
result = append(result, api.ReactionResponse{ |
|
|
|
result = append(result, api.Reaction{ |
|
|
|
User: r.User.APIFormat(), |
|
|
|
User: r.User.APIFormat(), |
|
|
|
Reaction: r.Type, |
|
|
|
Reaction: r.Type, |
|
|
|
Created: r.CreatedUnix.AsTime(), |
|
|
|
Created: r.CreatedUnix.AsTime(), |
|
|
@ -317,8 +320,10 @@ func PostIssueReaction(ctx *context.APIContext, form api.EditReactionOption) { |
|
|
|
// schema:
|
|
|
|
// schema:
|
|
|
|
// "$ref": "#/definitions/EditReactionOption"
|
|
|
|
// "$ref": "#/definitions/EditReactionOption"
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
|
|
|
|
|
// "200":
|
|
|
|
|
|
|
|
// "$ref": "#/responses/Reaction"
|
|
|
|
// "201":
|
|
|
|
// "201":
|
|
|
|
// "$ref": "#/responses/ReactionResponse"
|
|
|
|
// "$ref": "#/responses/Reaction"
|
|
|
|
// "403":
|
|
|
|
// "403":
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
// "$ref": "#/responses/forbidden"
|
|
|
|
|
|
|
|
|
|
|
@ -386,19 +391,20 @@ func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, i |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if models.IsErrForbiddenIssueReaction(err) { |
|
|
|
if models.IsErrForbiddenIssueReaction(err) { |
|
|
|
ctx.Error(http.StatusForbidden, err.Error(), err) |
|
|
|
ctx.Error(http.StatusForbidden, err.Error(), err) |
|
|
|
|
|
|
|
} else if models.IsErrReactionAlreadyExist(err) { |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, api.Reaction{ |
|
|
|
|
|
|
|
User: ctx.User.APIFormat(), |
|
|
|
|
|
|
|
Reaction: reaction.Type, |
|
|
|
|
|
|
|
Created: reaction.CreatedUnix.AsTime(), |
|
|
|
|
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.Error(http.StatusInternalServerError, "CreateCommentReaction", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "CreateCommentReaction", err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
_, err = reaction.LoadUser() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "Reaction.LoadUser()", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.JSON(http.StatusCreated, api.ReactionResponse{ |
|
|
|
ctx.JSON(http.StatusCreated, api.Reaction{ |
|
|
|
User: reaction.User.APIFormat(), |
|
|
|
User: ctx.User.APIFormat(), |
|
|
|
Reaction: reaction.Type, |
|
|
|
Reaction: reaction.Type, |
|
|
|
Created: reaction.CreatedUnix.AsTime(), |
|
|
|
Created: reaction.CreatedUnix.AsTime(), |
|
|
|
}) |
|
|
|
}) |
|
|
|