API: handle reactions to comments #4032

Closed
opened 2025-11-02 05:34:56 -06:00 by GiteaMirror · 20 comments
Owner

Originally created by @6543 on GitHub (Sep 29, 2019).

GET     /repos/{owner}/{repo}/issues/comments/{id}/reactions
PUT     /repos/{owner}/{repo}/issues/comments/{id}/reactions
DELETE  /repos/{owner}/{repo}/issues/comments/{id}/reactions
Originally created by @6543 on GitHub (Sep 29, 2019). ``` GET /repos/{owner}/{repo}/issues/comments/{id}/reactions PUT /repos/{owner}/{repo}/issues/comments/{id}/reactions DELETE /repos/{owner}/{repo}/issues/comments/{id}/reactions ```
GiteaMirror added the type/enhancementmodifies/api labels 2025-11-02 05:34:56 -06:00
Author
Owner

@6543 commented on GitHub (Nov 2, 2019):

GitHub docu https://developer.github.com/v3/issues/comments/#reactions-summary
think we can do better

@6543 commented on GitHub (Nov 2, 2019): GitHub docu https://developer.github.com/v3/issues/comments/#reactions-summary think we can do better
Author
Owner

@6543 commented on GitHub (Nov 3, 2019):

@mmarif4u what is earyer to process:

for GET /repos/{owner}/{repo}/issues/comments/{id}/reactions

Either

[
  {
    "id": 0,
    "username": "6543",
    "reaction": "heart",
  },
  {
    "id": 4,
    "username": "6543",
    "reaction": "laugh",
  },
  {
    "id": 8,
    "username": "mmarif",
    "reaction": "laugh",
  },
  {
    "id": 10,
    "username": "user1",
    "reaction": "confused",
  }
]

Or

[
  {
    "reaction": "heart",
    "users": [ "6543" ]
  },
  {
    "reaction": "laugh",
    "users": [ "6543", "mmarif" ]
  },
  {
    "reaction": "confused",
    "users": [ "user1" ]
  }
]

PS: i dont like to send whole User.APIFormat() user this would generate to mouch overhead

@6543 commented on GitHub (Nov 3, 2019): @mmarif4u what is earyer to process: for `GET /repos/{owner}/{repo}/issues/comments/{id}/reactions` # Either ```json [ { "id": 0, "username": "6543", "reaction": "heart", }, { "id": 4, "username": "6543", "reaction": "laugh", }, { "id": 8, "username": "mmarif", "reaction": "laugh", }, { "id": 10, "username": "user1", "reaction": "confused", } ] ``` # Or ```json [ { "reaction": "heart", "users": [ "6543" ] }, { "reaction": "laugh", "users": [ "6543", "mmarif" ] }, { "reaction": "confused", "users": [ "user1" ] } ] ``` PS: i dont like to send whole User.APIFormat() user this would generate to mouch overhead
Author
Owner

@guillep2k commented on GitHub (Nov 3, 2019):

[
  {
    "reaction": "heart",
    "users": [ "6543" ]
  },
  {
    "reaction": "laugh",
    "users": [ "6543", "mmarif" ]
  },
  {
    "reaction": "confused",
    "users": [ "user1" ]
  }
]

Is better: more concise, no ids exposed.

@guillep2k commented on GitHub (Nov 3, 2019): ``` [ { "reaction": "heart", "users": [ "6543" ] }, { "reaction": "laugh", "users": [ "6543", "mmarif" ] }, { "reaction": "confused", "users": [ "user1" ] } ] ``` Is better: more concise, no ids exposed.
Author
Owner

@mmarif4u commented on GitHub (Nov 4, 2019):

I agree with @guillep2k, that is the right way to do it. 👍

@mmarif4u commented on GitHub (Nov 4, 2019): I agree with @guillep2k, that is the right way to do it. :+1:
Author
Owner

@6543 commented on GitHub (Nov 5, 2019):

PUT / DELETE use as body

{
    "reaction": "heart",
    "users": [ "6543" ]
 }

I could make it eaven mor simpler by just allow a string to be send or

"reaction": "heart"

but i leave it open so admins have an API to send ractions for other users/bots... too

@6543 commented on GitHub (Nov 5, 2019): PUT / DELETE use as body ```json { "reaction": "heart", "users": [ "6543" ] } ``` I could make it eaven mor simpler by just allow a `string` to be send or ```json "reaction": "heart" ``` but i leave it open so admins have an API to send ractions for other users/bots... too
Author
Owner

@zeripath commented on GitHub (Nov 5, 2019):

Don't forget Sudo allows an admin to act like any other user - so you should only add that if you're going to allow the admin to set multiple user's reactions.

@zeripath commented on GitHub (Nov 5, 2019): Don't forget Sudo allows an admin to act like any other user - so you should only add that if you're going to allow the admin to set multiple user's reactions.
Author
Owner

@lafriks commented on GitHub (Nov 5, 2019):

imho we should follow GitHub API compatibility:
https://developer.github.com/v3/reactions/

Link above is just reaction counts by type in issue details API

@lafriks commented on GitHub (Nov 5, 2019): imho we should follow GitHub API compatibility: https://developer.github.com/v3/reactions/ Link above is just reaction counts by type in issue details API
Author
Owner

@6543 commented on GitHub (Nov 5, 2019):

@lafriks @techknowlogick one downside:

consider a issue with 15 comments -> each had ~ 10 reactions
-> api return user information in the worst case 150 times (dedundancy)
and if there all other users we still load a huge amount of user information wich isnt used ...
and if an app like to load more about a user it still kan get it by its name

I'm thinking about mobile conection ...

@lafriks add more fields beside the user{} can be usefull but should i expose the reaction ID (-> @guillep2k)?

@6543 commented on GitHub (Nov 5, 2019): @lafriks @techknowlogick one downside: consider a issue with 15 comments -> each had ~ 10 reactions -> api return user information in the worst case 150 times (dedundancy) and if there all other users we still load a huge amount of user information wich isnt used ... and if an app like to load more about a user it still kan get it by its name I'm thinking about mobile conection ... @lafriks add more fields beside the user{} can be usefull but should i expose the reaction ID (-> @guillep2k)?
Author
Owner

@6543 commented on GitHub (Nov 5, 2019):

proposal2

GET /repos/{owner}/{repo}/issues/comments/{id}/reactions
consume: null
return:

[
  {
    "user": "octocat",
    "content": "heart",
    "created_at": "2016-05-20T20:09:31Z"
  },
  {
    "user": "6543",
    "content": "heart",
    "created_at": "2017-10-20T20:09:31Z"
  }
]

PUT/DELETE /repos/{owner}/{repo}/issues/comments/{id}/reactions
consume:

content: "heart"

return:

[
  {
    "user": "octocat",
    "content": "heart",
    "created_at": "2016-05-20T20:09:31Z"
  }
]
@6543 commented on GitHub (Nov 5, 2019): # proposal2 `GET /repos/{owner}/{repo}/issues/comments/{id}/reactions` **consume:** `null` **return:** ```json [ { "user": "octocat", "content": "heart", "created_at": "2016-05-20T20:09:31Z" }, { "user": "6543", "content": "heart", "created_at": "2017-10-20T20:09:31Z" } ] ``` `PUT/DELETE /repos/{owner}/{repo}/issues/comments/{id}/reactions` **consume:** ```json content: "heart" ``` **return:** ```json [ { "user": "octocat", "content": "heart", "created_at": "2016-05-20T20:09:31Z" } ] ```
Author
Owner

@lafriks commented on GitHub (Nov 6, 2019):

I don't agree as most probably you will still want to have user avatar url, user url, we do return this format in all other api, so I would not like this to be different. Reaction summary (counts by type) you will already have them in issue/pr/comment API. These are details so you really need to request them rarely - when you really want to know exact details

@lafriks commented on GitHub (Nov 6, 2019): I don't agree as most probably you will still want to have user avatar url, user url, we do return this format in all other api, so I would not like this to be different. Reaction summary (counts by type) you will already have them in issue/pr/comment API. These are details so you really need to request them rarely - when you really want to know exact details
Author
Owner

@6543 commented on GitHub (Nov 7, 2019):

@lafriks
GET /repos/{owner}/{repo}/issues/{index} as no reaction info
GET /repos/{owner}/{repo}/pulls/{index} also

a GET /repos/{owner}/{repo}/issues/comments/{id} do NOT exist!
and GET /repos/{owner}/{repo}/issues/comments has no reaction info

this is same at GET /repos/{owner}/{repo}/issues/{index}/comments

@6543 commented on GitHub (Nov 7, 2019): @lafriks `GET /repos/{owner}/{repo}/issues/{index}` as no reaction info `GET /repos/{owner}/{repo}/pulls/{index}` also a `GET /repos/{owner}/{repo}/issues/comments/{id}` do NOT exist! and `GET /repos/{owner}/{repo}/issues/comments` has no reaction info this is same at `GET /repos/{owner}/{repo}/issues/{index}/comments`
Author
Owner

@6543 commented on GitHub (Nov 7, 2019):

so add a "reactions_light" or so type wich has smal foodprint to ⬆️ API endpoints?

and make /repos/{owner}/{repo}/issues/comments/{id}/reactions like github?

@6543 commented on GitHub (Nov 7, 2019): so add a "reactions_light" or so type wich has smal foodprint to :arrow_up: API endpoints? and make `/repos/{owner}/{repo}/issues/comments/{id}/reactions` like github?
Author
Owner

@6543 commented on GitHub (Nov 7, 2019):

@lafriks github has a similar aproach: https://developer.github.com/v3/issues/#reactions-summary

@6543 commented on GitHub (Nov 7, 2019): @lafriks github has a similar aproach: https://developer.github.com/v3/issues/#reactions-summary
Author
Owner

@6543 commented on GitHub (Nov 7, 2019):

one thing wich is not goog at this reaction_summary_api:
parsing it with custom reactions is not that great - i dont like to hardcode reaction types to a data struct!

@6543 commented on GitHub (Nov 7, 2019): one thing wich is not goog at this reaction_summary_api: parsing it with custom reactions is not that great - i dont like to **hardcode** reaction **types** to a data struct!
Author
Owner

@6543 commented on GitHub (Nov 7, 2019):

@lafriks I'm thinking of #8811

@6543 commented on GitHub (Nov 7, 2019): @lafriks I'm thinking of #8811
Author
Owner

@6543 commented on GitHub (Nov 7, 2019):

Proposal.3

reaction endpoint

GET /repos/{owner}/{repo}/issues/comments/{id}/reactions
consume: null
return:

[
  {
    "id": 1,
    "user": {
      "login": "octocat",
      "id": 1,
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "url": "https://api.github.com/users/octocat",
      ..... (gitea_api_user) 
      "type": "User",
      "site_admin": false
    },
    "content": "heart",
    "created_at": "2016-05-20T20:09:31Z"
  }
]

PUT/DELETE /repos/{owner}/{repo}/issues/comments/{id}/reactions
consume:

content: "heart"

return:
http code

Extend issue/pr/comment API

add a reaction field: (api.reaction_summary)

"reactions": [
  {
    "reaction": "heart",
    "users": [ "6543" ],
    "count": 1
  },
  {
    "reaction": "rocket",
    "users": [ "octa" ],
    "count": 1
  }
],
"reactions_count": 2,
"reactions_url": "/repos/{owner}/{repo}/<issues/comments/pull ...>/{id}/reactions"
@6543 commented on GitHub (Nov 7, 2019): # Proposal.3 ## reaction endpoint `GET /repos/{owner}/{repo}/issues/comments/{id}/reactions` **consume:** `null` **return:** ```json [ { "id": 1, "user": { "login": "octocat", "id": 1, "avatar_url": "https://github.com/images/error/octocat_happy.gif", "url": "https://api.github.com/users/octocat", ..... (gitea_api_user) "type": "User", "site_admin": false }, "content": "heart", "created_at": "2016-05-20T20:09:31Z" } ] ``` `PUT/DELETE /repos/{owner}/{repo}/issues/comments/{id}/reactions` **consume:** ```json content: "heart" ``` **return:** http code ## Extend issue/pr/comment API add a reaction field: (api.reaction_summary) ```json "reactions": [ { "reaction": "heart", "users": [ "6543" ], "count": 1 }, { "reaction": "rocket", "users": [ "octa" ], "count": 1 } ], "reactions_count": 2, "reactions_url": "/repos/{owner}/{repo}/<issues/comments/pull ...>/{id}/reactions" ```
Author
Owner

@lafriks commented on GitHub (Nov 8, 2019):

Extend issue/pr/comment API

Github API for this is better imho

"reactions": {
  "total_count": 5,
  "+1": 3,
  "-1": 1,
  "laugh": 0,
  "confused": 0,
  "heart": 1,
  "hooray": 0,
  "url": "{owner}/{repo}/issues/comments/{id}/reactions"
}
@lafriks commented on GitHub (Nov 8, 2019): ### Extend issue/pr/comment API Github API for this is better imho ```json "reactions": { "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "url": "{owner}/{repo}/issues/comments/{id}/reactions" } ```
Author
Owner

@6543 commented on GitHub (Nov 8, 2019):

@lafriks what if i like to add "rocket" 🚀?
this is no array. types are hardcoded :(
and if we like support for custom reactions we cant provide a usefull summary representation

@6543 commented on GitHub (Nov 8, 2019): @lafriks what if i like to add "rocket" :rocket:? this is no array. types are hardcoded :( and if we like support for custom reactions we cant provide a usefull summary representation
Author
Owner

@6543 commented on GitHub (Nov 8, 2019):

I'll do it the github way, but don't blame me for limitating api afterwards ...

@6543 commented on GitHub (Nov 8, 2019): I'll do it the github way, but don't blame me for limitating api afterwards ...
Author
Owner

@6543 commented on GitHub (Dec 2, 2019):

Gitea Reactions Summary

"reactions_summary": [
  {
    "reaction": "heart",
    "users": [ "6543" ],
    "count": 1
  },
  {
    "reaction": "rocket",
    "users": [ "octa" ],
    "count": 1
  }
],
"reactions_counter": 2,

EDIT: wont imlement jet - only if somebody need this, if so comment on this issue :D

@6543 commented on GitHub (Dec 2, 2019): ## Gitea Reactions Summary ```json "reactions_summary": [ { "reaction": "heart", "users": [ "6543" ], "count": 1 }, { "reaction": "rocket", "users": [ "octa" ], "count": 1 } ], "reactions_counter": 2, ``` EDIT: wont imlement jet - only if somebody need this, if so comment on this issue :D
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4032