Enhance Notification System with New API Endpoints and Response Structures

- Added new endpoints for marking notifications as seen and retrieving detailed notification information for both admin and user contexts, improving the flexibility of the notification system.
- Implemented the MarkSeen and ViewNotification methods in the NotificationHandler, ensuring proper handling of notification visibility and details retrieval.
- Updated the NotificationService interface to include methods for getting notification details and marking notifications as seen, enhancing service capabilities.
- Enhanced the notification response structures to include additional fields such as Image, Seen, and ScheduledAt, providing richer data in API responses.
- Updated API documentation with Swagger comments for the new endpoints and response formats, ensuring clarity for API consumers.
This commit is contained in:
n.nakhostin
2025-09-21 11:26:54 +03:30
parent 0f981880b5
commit 5906904caf
12 changed files with 1200 additions and 45 deletions
+323 -9
View File
@@ -2619,6 +2619,55 @@ const docTemplate = `{
}
}
},
"/admin/v1/notifications/mark-seen/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Mark a notification as seen",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Mark a notification as seen",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/admin/v1/notifications/my": {
"get": {
"security": [
@@ -2739,6 +2788,73 @@ const docTemplate = `{
}
}
},
"/admin/v1/notifications/view/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get detailed information about a specific notification",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get notification details",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/admin/v1/profile": {
"get": {
"security": [
@@ -5257,7 +5373,7 @@ const docTemplate = `{
}
}
},
"/api/v1/notifications/my": {
"/api/v1/notifications": {
"get": {
"security": [
{
@@ -5377,6 +5493,122 @@ const docTemplate = `{
}
}
},
"/api/v1/notifications/mark-seen/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Mark a notification as seen",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Notification"
],
"summary": "Mark a notification as seen",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/notifications/view/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get detailed information about a specific notification",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Notification"
],
"summary": "Get notification details",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/notification.DetailedNotificationResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/profile": {
"get": {
"security": [
@@ -7297,10 +7529,6 @@ const docTemplate = `{
"type": "string",
"example": "User"
},
"password": {
"type": "string",
"example": "User!1234"
},
"phone": {
"type": "string",
"example": "+1234567890"
@@ -7627,9 +7855,6 @@ const docTemplate = `{
"type": "object",
"properties": {
"created_at": {
"type": "integer"
},
"description": {
"type": "string"
},
"event_type": {
@@ -7638,9 +7863,18 @@ const docTemplate = `{
"id": {
"type": "string"
},
"image": {
"type": "string"
},
"is_scheduled": {
"type": "boolean"
},
"link": {
"type": "string"
},
"message": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {}
@@ -7657,6 +7891,15 @@ const docTemplate = `{
"schedule_at": {
"type": "integer"
},
"scheduled_at": {
"type": "integer"
},
"seen": {
"type": "boolean"
},
"seen_at": {
"type": "integer"
},
"status": {
"type": "string"
},
@@ -7667,7 +7910,7 @@ const docTemplate = `{
"type": "string"
},
"updated_at": {
"type": "integer"
"type": "string"
},
"user_id": {
"type": "string"
@@ -7685,6 +7928,77 @@ const docTemplate = `{
"DeliveryChannelEmail"
]
},
"notification.DetailedNotificationResponse": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"event_type": {
"type": "string"
},
"id": {
"type": "string"
},
"image": {
"type": "string"
},
"is_scheduled": {
"type": "boolean"
},
"link": {
"type": "string"
},
"message": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {}
},
"methods": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"priority": {
"description": "low, medium, important",
"type": "string"
},
"scheduled_at": {
"type": "integer"
},
"seen": {
"type": "boolean"
},
"seen_at": {
"type": "integer"
},
"status": {
"description": "pending, sent, failed",
"type": "string"
},
"title": {
"type": "string"
},
"type": {
"description": "info, warning, alert, reject",
"type": "string"
},
"updated_at": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
}
}
},
"notification.NotificationPriority": {
"type": "string",
"enum": [
+323 -9
View File
@@ -2613,6 +2613,55 @@
}
}
},
"/admin/v1/notifications/mark-seen/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Mark a notification as seen",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Mark a notification as seen",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/admin/v1/notifications/my": {
"get": {
"security": [
@@ -2733,6 +2782,73 @@
}
}
},
"/admin/v1/notifications/view/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get detailed information about a specific notification",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get notification details",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/admin/v1/profile": {
"get": {
"security": [
@@ -5251,7 +5367,7 @@
}
}
},
"/api/v1/notifications/my": {
"/api/v1/notifications": {
"get": {
"security": [
{
@@ -5371,6 +5487,122 @@
}
}
},
"/api/v1/notifications/mark-seen/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Mark a notification as seen",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Notification"
],
"summary": "Mark a notification as seen",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/notifications/view/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get detailed information about a specific notification",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Notification"
],
"summary": "Get notification details",
"parameters": [
{
"type": "string",
"description": "Notification ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/notification.DetailedNotificationResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/profile": {
"get": {
"security": [
@@ -7291,10 +7523,6 @@
"type": "string",
"example": "User"
},
"password": {
"type": "string",
"example": "User!1234"
},
"phone": {
"type": "string",
"example": "+1234567890"
@@ -7621,9 +7849,6 @@
"type": "object",
"properties": {
"created_at": {
"type": "integer"
},
"description": {
"type": "string"
},
"event_type": {
@@ -7632,9 +7857,18 @@
"id": {
"type": "string"
},
"image": {
"type": "string"
},
"is_scheduled": {
"type": "boolean"
},
"link": {
"type": "string"
},
"message": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {}
@@ -7651,6 +7885,15 @@
"schedule_at": {
"type": "integer"
},
"scheduled_at": {
"type": "integer"
},
"seen": {
"type": "boolean"
},
"seen_at": {
"type": "integer"
},
"status": {
"type": "string"
},
@@ -7661,7 +7904,7 @@
"type": "string"
},
"updated_at": {
"type": "integer"
"type": "string"
},
"user_id": {
"type": "string"
@@ -7679,6 +7922,77 @@
"DeliveryChannelEmail"
]
},
"notification.DetailedNotificationResponse": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"event_type": {
"type": "string"
},
"id": {
"type": "string"
},
"image": {
"type": "string"
},
"is_scheduled": {
"type": "boolean"
},
"link": {
"type": "string"
},
"message": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {}
},
"methods": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"priority": {
"description": "low, medium, important",
"type": "string"
},
"scheduled_at": {
"type": "integer"
},
"seen": {
"type": "boolean"
},
"seen_at": {
"type": "integer"
},
"status": {
"description": "pending, sent, failed",
"type": "string"
},
"title": {
"type": "string"
},
"type": {
"description": "info, warning, alert, reject",
"type": "string"
},
"updated_at": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
}
}
},
"notification.NotificationPriority": {
"type": "string",
"enum": [
+204 -7
View File
@@ -469,9 +469,6 @@ definitions:
full_name:
example: User
type: string
password:
example: User!1234
type: string
phone:
example: "+1234567890"
type: string
@@ -693,15 +690,19 @@ definitions:
internal_notification.NotificationResponse:
properties:
created_at:
type: integer
description:
type: string
event_type:
type: string
id:
type: string
image:
type: string
is_scheduled:
type: boolean
link:
type: string
message:
type: string
metadata:
additionalProperties: {}
type: object
@@ -713,6 +714,12 @@ definitions:
type: string
schedule_at:
type: integer
scheduled_at:
type: integer
seen:
type: boolean
seen_at:
type: integer
status:
type: string
title:
@@ -720,7 +727,7 @@ definitions:
type:
type: string
updated_at:
type: integer
type: string
user_id:
type: string
type: object
@@ -732,6 +739,54 @@ definitions:
x-enum-varnames:
- DeliveryChannelPush
- DeliveryChannelEmail
notification.DetailedNotificationResponse:
properties:
data:
properties:
created_at:
type: string
event_type:
type: string
id:
type: string
image:
type: string
is_scheduled:
type: boolean
link:
type: string
message:
type: string
metadata:
additionalProperties: {}
type: object
methods:
additionalProperties:
type: string
type: object
priority:
description: low, medium, important
type: string
scheduled_at:
type: integer
seen:
type: boolean
seen_at:
type: integer
status:
description: pending, sent, failed
type: string
title:
type: string
type:
description: info, warning, alert, reject
type: string
updated_at:
type: string
user_id:
type: string
type: object
type: object
notification.NotificationPriority:
enum:
- low
@@ -2874,6 +2929,37 @@ paths:
summary: Create a new notification
tags:
- Admin-Notification
/admin/v1/notifications/mark-seen/{id}:
get:
consumes:
- application/json
description: Mark a notification as seen
parameters:
- description: Notification ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Mark a notification as seen
tags:
- Admin-Notification
/admin/v1/notifications/my:
get:
consumes:
@@ -2949,6 +3035,46 @@ paths:
summary: Get notifications for the admin
tags:
- Admin-Notification
/admin/v1/notifications/view/{id}:
get:
consumes:
- application/json
description: Get detailed information about a specific notification
parameters:
- description: Notification ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/internal_notification.NotificationResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get notification details
tags:
- Admin-Notification
/admin/v1/profile:
get:
consumes:
@@ -4518,7 +4644,7 @@ paths:
summary: Create new inquiry
tags:
- Inquiries
/api/v1/notifications/my:
/api/v1/notifications:
get:
consumes:
- application/json
@@ -4593,6 +4719,77 @@ paths:
summary: Get notifications for the user
tags:
- Notification
/api/v1/notifications/mark-seen/{id}:
get:
consumes:
- application/json
description: Mark a notification as seen
parameters:
- description: Notification ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.APIResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Mark a notification as seen
tags:
- Notification
/api/v1/notifications/view/{id}:
get:
consumes:
- application/json
description: Get detailed information about a specific notification
parameters:
- description: Notification ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/notification.DetailedNotificationResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get notification details
tags:
- Notification
/api/v1/profile:
get:
consumes: