OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add emoji reactions openapi specification
Kabiru Mwenja4788f0121238
diff --git a/docs/api/apiv3/components/examples/activity_response.yml b/docs/api/apiv3/components/examples/activity_response.ymlindex b424c9e77af..b0d4d252d0d 100644--- a/docs/api/apiv3/components/examples/activity_response.yml+++ b/docs/api/apiv3/components/examples/activity_response.yml@@ -21,6 +21,11 @@ value:id: 207_type: WorkPackage_hint: Work package resource shortened for brevity.+ emojiReactions:+ _type: Collection+ total: 1+ count: 1+ _hint: Emoji reactions resource shortened for brevity._links:attachments:href: "/api/v3/activities/1478/attachments"diff --git a/docs/api/apiv3/components/schemas/activity_model.yml b/docs/api/apiv3/components/schemas/activity_model.ymlindex f02f905ebc5..71d4af8c034 100644--- a/docs/api/apiv3/components/schemas/activity_model.yml+++ b/docs/api/apiv3/components/schemas/activity_model.yml@@ -40,10 +40,14 @@ properties:- $ref: './work_package_model.yml'- description: |-The work package this activity belongs to-+# Conditions-+Only embedded when the `journable` of the activity is a work package+ emojiReactions:+ allOf:+ - $ref: './emoji_reactions_model.yml'+ - description: Collection of emoji reactions for this activity_links:type: objectproperties:@@ -87,9 +91,16 @@ properties:# Conditions- **Permissions**:+ **Permissions**:- `add_work_package_comments`- for internal comments: `add_internal_comments`+ emojiReactions:+ allOf:+ - $ref: './link.yml'+ - description: |-+ The emoji reactions collection of this activity++ **Resource**: EmojiReactionsexample:id: 1_type: Activity::Comment@@ -133,6 +144,47 @@ example:_links:self:href: "/api/v3/activities/79090/attachments"+ emojiReactions:+ _type: Collection+ total: 2+ count: 2+ _embedded:+ elements:+ - _type: "EmojiReaction"+ id: "1-thumbs_up"+ reaction: "thumbs_up"+ emoji: "👍"+ reactionsCount: 3+ firstReactionAt: "2024-04-08T15:37:19.275Z"+ _links:+ self:+ href: "/api/v3/emoji_reactions/1-thumbs_up"+ reactable:+ href: "/api/v3/activities/1"+ reactingUsers:+ - href: "/api/v3/users/435"+ title: "John Doe"+ - href: "/api/v3/users/436"+ title: "Jane Smith"+ - href: "/api/v3/users/437"+ title: "Bob Johnson"+ - _type: "EmojiReaction"+ id: "1-heart"+ reaction: "heart"+ emoji: "❤️"+ reactionsCount: 1+ firstReactionAt: "2024-04-08T15:38:19.275Z"+ _links:+ self:+ href: "/api/v3/emoji_reactions/1-heart"+ reactable:+ href: "/api/v3/activities/1"+ reactingUsers:+ - href: "/api/v3/users/435"+ title: "John Doe"+ _links:+ self:+ href: "/api/v3/activities/1/emoji_reactions"workPackage:_type: WorkPackageid: 10403@@ -181,6 +233,8 @@ example:title: John Sheppard - adminattachments:href: "/api/v3/activities/1/attachments"+ emojiReactions:+ href: "/api/v3/activities/1/emoji_reactions"addAttachment:href: "/api/v3/activities/1/attachments"method: postdiff --git a/docs/api/apiv3/components/schemas/emoji_reaction_model.yml b/docs/api/apiv3/components/schemas/emoji_reaction_model.ymlnew file mode 100644index 00000000000..6e8fe0fa401--- /dev/null+++ b/docs/api/apiv3/components/schemas/emoji_reaction_model.yml@@ -0,0 +1,65 @@+# Schema: EmojiReactionModel+---+type: object+properties:+ _type:+ type: string+ enum:+ - "EmojiReaction"+ id:+ type: string+ description: "Emoji reaction id (format: reactable_id-reaction)"+ example: "1-thumbs_up"+ reaction:+ type: string+ description: The reaction identifier+ example: "thumbs_up"+ emoji:+ type: string+ description: The emoji character+ example: "👍"+ reactionsCount:+ type: integer+ description: Number of users who reacted with this emoji+ minimum: 1+ example: 3+ firstReactionAt:+ type: string+ format: date-time+ description: Time of the first reaction+ _links:+ type: object+ properties:+ self:+ allOf:+ - $ref: './link.yml'+ - description: This emoji reaction+ reactable:+ allOf:+ - $ref: './link.yml'+ - description: The activity this emoji reaction belongs to+ reactingUsers:+ type: array+ items:+ allOf:+ - $ref: './link.yml'+ - description: The users who reacted with this emoji+example:+ _type: "EmojiReaction"+ id: "1-thumbs_up"+ reaction: "thumbs_up"+ emoji: "👍"+ reactionsCount: 3+ firstReactionAt: "2024-04-08T15:37:19.275Z"+ _links:+ self:+ href: "/api/v3/emoji_reactions/1-thumbs_up"+ reactable:+ href: "/api/v3/activities/1"+ reactingUsers:+ - href: "/api/v3/users/435"+ title: "John Doe"+ - href: "/api/v3/users/436"+ title: "Jane Smith"+ - href: "/api/v3/users/437"+ title: "Bob Johnson"diff --git a/docs/api/apiv3/components/schemas/emoji_reactions_model.yml b/docs/api/apiv3/components/schemas/emoji_reactions_model.ymlnew file mode 100644index 00000000000..36a21b44f1c--- /dev/null+++ b/docs/api/apiv3/components/schemas/emoji_reactions_model.yml@@ -0,0 +1,71 @@+# Schema: EmojiReactionsModel+---+type: object+properties:+ _type:+ type: string+ enum:+ - "Collection"+ total:+ type: integer+ description: Total number of emoji reactions+ minimum: 0+ count:+ type: integer+ description: Number of emoji reactions in this response+ minimum: 0+ _embedded:+ type: object+ properties:+ elements:+ type: array+ items:+ $ref: './emoji_reaction_model.yml'+ _links:+ type: object+ properties:+ self:+ allOf:+ - $ref: './link.yml'+ - description: This collection+example:+ _type: "Collection"+ total: 2+ count: 2+ _embedded:+ elements:+ - _type: "EmojiReaction"+ id: "1-thumbs_up"+ reaction: "thumbs_up"+ emoji: "👍"+ reactionsCount: 3+ firstReactionAt: "2024-04-08T15:37:19.275Z"+ _links:+ self:+ href: "/api/v3/emoji_reactions/1-thumbs_up"+ reactable:+ href: "/api/v3/activities/1"+ reactingUsers:+ - href: "/api/v3/users/435"+ title: "John Doe"+ - href: "/api/v3/users/436"+ title: "Jane Smith"+ - href: "/api/v3/users/437"+ title: "Bob Johnson"+ - _type: "EmojiReaction"+ id: "1-heart"+ reaction: "heart"+ emoji: "❤️"+ reactionsCount: 1+ firstReactionAt: "2024-04-08T15:38:19.275Z"+ _links:+ self:+ href: "/api/v3/emoji_reactions/1-heart"+ reactable:+ href: "/api/v3/activities/1"+ reactingUsers:+ - href: "/api/v3/users/435"+ title: "John Doe"+ _links:+ self:+ href: "/api/v3/activities/1/emoji_reactions"diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.ymlindex a104499d688..f3efa45c893 100644--- a/docs/api/apiv3/openapi-spec.yml+++ b/docs/api/apiv3/openapi-spec.yml@@ -172,6 +172,8 @@ paths:"$ref": "./paths/activity.yml""/api/v3/activities/{id}/attachments":"$ref": "./paths/activity_attachments.yml"+ "/api/v3/activities/{id}/emoji_reactions":+ "$ref": "./paths/activity_emoji_reactions.yml""/api/v3/attachments":"$ref": "./paths/attachments.yml""/api/v3/attachments/{id}":@@ -472,6 +474,8 @@ paths:"$ref": "./paths/work_package.yml""/api/v3/work_packages/{id}/activities":"$ref": "./paths/work_package_activities.yml"+ "/api/v3/work_packages/{id}/activities_emoji_reactions":+ "$ref": "./paths/work_package_activities_emoji_reactions.yml""/api/v3/work_packages/{id}/attachments":"$ref": "./paths/work_package_attachments.yml""/api/v3/work_packages/{id}/available_assignees":@@ -935,6 +939,10 @@ components:"$ref": "./components/schemas/work_package_activities_model.yml"Work_PackagesModel:"$ref": "./components/schemas/work_packages_model.yml"+ EmojiReactionModel:+ "$ref": "./components/schemas/emoji_reaction_model.yml"+ EmojiReactions_Model:+ "$ref": "./components/schemas/emoji_reactions_model.yml"securitySchemes:BasicAuth:type: httpdiff --git a/docs/api/apiv3/paths/activity_emoji_reactions.yml b/docs/api/apiv3/paths/activity_emoji_reactions.ymlnew file mode 100644index 00000000000..b014e9f1cd0--- /dev/null+++ b/docs/api/apiv3/paths/activity_emoji_reactions.yml@@ -0,0 +1,45 @@+# /api/v3/activities/{id}/emoji_reactions+---+get:+ summary: List emoji reactions by activity+ operationId: list_activity_emoji_reactions+ tags:+ - Activities+ - EmojiReactions+ description: List all emoji reactions of a single activity.+ parameters:+ - name: id+ description: ID of the activity whose emoji reactions will be listed+ in: path+ required: true+ schema:+ type: integer+ example: '1'+ responses:+ '200':+ description: OK+ content:+ application/hal+json:+ schema:+ $ref: '../components/schemas/emoji_reactions_model.yml'+ '404':+ content:+ application/hal+json:+ schema:+ $ref: '../components/schemas/error_response.yml'+ examples:+ response:+ value:+ _type: Error+ errorIdentifier: urn:openproject-org:api:v3:errors:NotFound+ message: The requested resource could not be found.+ description: |-+ Returned if the activity does not exist or the client does not have sufficient permissions+ to see it.++ **Required permission:**+ - `view_work_packages`+ - for internal comments: `view_internal_comments`++ *Note: A client without sufficient permissions shall not be able to test for the existence of an activity.+ That's why a 404 is returned here, even if a 403 might be more appropriate.*diff --git a/docs/api/apiv3/paths/work_package_activities_emoji_reactions.yml b/docs/api/apiv3/paths/work_package_activities_emoji_reactions.ymlnew file mode 100644index 00000000000..3c2675b8a01--- /dev/null+++ b/docs/api/apiv3/paths/work_package_activities_emoji_reactions.yml@@ -0,0 +1,46 @@+# /api/v3/work_packages/{id}/activities_emoji_reactions+---+get:+ summary: List emoji reactions by work package activities+ operationId: list_work_package_activities_emoji_reactions+ tags:+ - WorkPackages+ - Activities+ - EmojiReactions+ description: List all emoji reactions of all activities of a single work package.+ parameters:+ - name: id+ description: ID of the work package whose activities' emoji reactions will be listed+ in: path+ required: true+ schema:+ type: integer+ example: '1'+ responses:+ '200':+ description: OK+ content:+ application/hal+json:+ schema:+ $ref: '../components/schemas/emoji_reactions_model.yml'+ '404':+ content:+ application/hal+json:+ schema:+ $ref: '../components/schemas/error_response.yml'+ examples:+ response:+ value:+ _type: Error+ errorIdentifier: urn:openproject-org:api:v3:errors:NotFound+ message: The requested resource could not be found.+ description: |-+ Returned if the work package does not exist or the client does not have sufficient permissions+ to see it.++ **Required permission:**+ - `view_work_packages`+ - for internal comments: `view_internal_comments`++ *Note: A client without sufficient permissions shall not be able to test for the existence of a work package.+ That's why a 404 is returned here, even if a 403 might be more appropriate.*diff --git a/lib/api/v3/activities/activity_representer.rb b/lib/api/v3/activities/activity_representer.rbindex f3669241413..5f4e6343ded 100644--- a/lib/api/v3/activities/activity_representer.rb+++ b/lib/api/v3/activities/activity_representer.rb@@ -62,6 +62,12 @@ module API}end+ link :emojiReactions do+ {+ href: api_v3_paths.emoji_reactions_by_activity_comment(represented.id)+ }+ end+property :id,render_nil: true