Enhance Notification Management with New Endpoints and Response Structures

- Added new endpoints for retrieving notifications for both admins and users, improving the flexibility of the notification system.
- Implemented query parameters for filtering notifications by status, method, event type, type, and recipient, enhancing usability.
- Introduced new response structures for notifications, including pagination information, to provide better data handling in API responses.
- Updated API documentation with Swagger comments for the new endpoints and response formats, ensuring clarity for API consumers.
- Refactored notification handling logic to support the new features, promoting a more robust notification management system.
This commit is contained in:
n.nakhostin
2025-09-20 17:41:21 +03:30
parent ab6eb3b3ed
commit 19cd346b1c
13 changed files with 1637 additions and 16 deletions
+428
View File
@@ -2451,7 +2451,130 @@ const docTemplate = `{
}
},
"/admin/v1/notifications": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get notifications",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get notifications",
"parameters": [
{
"type": "string",
"description": "Status filter",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Method filter",
"name": "method",
"in": "query"
},
{
"type": "string",
"description": "Event type filter",
"name": "event_type",
"in": "query"
},
{
"type": "string",
"description": "Type filter",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Recipient filter",
"name": "recipient",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "string",
"description": "Sort field",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"description": "Sort order",
"name": "sort_order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationListResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Create a new notification with the provided information",
"consumes": [
"application/json"
@@ -2496,6 +2619,126 @@ const docTemplate = `{
}
}
},
"/admin/v1/notifications/my": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get notifications for the admin",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get notifications for the admin",
"parameters": [
{
"type": "string",
"description": "Status filter",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Method filter",
"name": "method",
"in": "query"
},
{
"type": "string",
"description": "Event type filter",
"name": "event_type",
"in": "query"
},
{
"type": "string",
"description": "Type filter",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Recipient filter",
"name": "recipient",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "string",
"description": "Sort field",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"description": "Sort order",
"name": "sort_order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationListResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/admin/v1/profile": {
"get": {
"security": [
@@ -5014,6 +5257,126 @@ const docTemplate = `{
}
}
},
"/api/v1/notifications/my": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get notifications for the user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Notification"
],
"summary": "Get notifications for the user",
"parameters": [
{
"type": "string",
"description": "Status filter",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Method filter",
"name": "method",
"in": "query"
},
{
"type": "string",
"description": "Event type filter",
"name": "event_type",
"in": "query"
},
{
"type": "string",
"description": "Type filter",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Recipient filter",
"name": "recipient",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "string",
"description": "Sort field",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"description": "Sort order",
"name": "sort_order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationListResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/profile": {
"get": {
"security": [
@@ -7205,6 +7568,20 @@ const docTemplate = `{
}
}
},
"internal_notification.NotificationListResponse": {
"type": "object",
"properties": {
"meta": {
"$ref": "#/definitions/response.Meta"
},
"notifications": {
"type": "array",
"items": {
"$ref": "#/definitions/internal_notification.NotificationResponse"
}
}
}
},
"internal_notification.NotificationRequest": {
"type": "object",
"properties": {
@@ -7246,6 +7623,57 @@ const docTemplate = `{
}
}
},
"internal_notification.NotificationResponse": {
"type": "object",
"properties": {
"created_at": {
"type": "integer"
},
"description": {
"type": "string"
},
"event_type": {
"type": "string"
},
"id": {
"type": "string"
},
"link": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {}
},
"methods": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"priority": {
"type": "string"
},
"schedule_at": {
"type": "integer"
},
"status": {
"type": "string"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
"updated_at": {
"type": "integer"
},
"user_id": {
"type": "string"
}
}
},
"notification.DeliveryChannel": {
"type": "string",
"enum": [
+428
View File
@@ -2445,7 +2445,130 @@
}
},
"/admin/v1/notifications": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get notifications",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get notifications",
"parameters": [
{
"type": "string",
"description": "Status filter",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Method filter",
"name": "method",
"in": "query"
},
{
"type": "string",
"description": "Event type filter",
"name": "event_type",
"in": "query"
},
{
"type": "string",
"description": "Type filter",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Recipient filter",
"name": "recipient",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "string",
"description": "Sort field",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"description": "Sort order",
"name": "sort_order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationListResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Create a new notification with the provided information",
"consumes": [
"application/json"
@@ -2490,6 +2613,126 @@
}
}
},
"/admin/v1/notifications/my": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get notifications for the admin",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin-Notification"
],
"summary": "Get notifications for the admin",
"parameters": [
{
"type": "string",
"description": "Status filter",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Method filter",
"name": "method",
"in": "query"
},
{
"type": "string",
"description": "Event type filter",
"name": "event_type",
"in": "query"
},
{
"type": "string",
"description": "Type filter",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Recipient filter",
"name": "recipient",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "string",
"description": "Sort field",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"description": "Sort order",
"name": "sort_order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationListResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/admin/v1/profile": {
"get": {
"security": [
@@ -5008,6 +5251,126 @@
}
}
},
"/api/v1/notifications/my": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get notifications for the user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Notification"
],
"summary": "Get notifications for the user",
"parameters": [
{
"type": "string",
"description": "Status filter",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Method filter",
"name": "method",
"in": "query"
},
{
"type": "string",
"description": "Event type filter",
"name": "event_type",
"in": "query"
},
{
"type": "string",
"description": "Type filter",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Recipient filter",
"name": "recipient",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "string",
"description": "Sort field",
"name": "sort_by",
"in": "query"
},
{
"type": "string",
"description": "Sort order",
"name": "sort_order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/internal_notification.NotificationListResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/profile": {
"get": {
"security": [
@@ -7199,6 +7562,20 @@
}
}
},
"internal_notification.NotificationListResponse": {
"type": "object",
"properties": {
"meta": {
"$ref": "#/definitions/response.Meta"
},
"notifications": {
"type": "array",
"items": {
"$ref": "#/definitions/internal_notification.NotificationResponse"
}
}
}
},
"internal_notification.NotificationRequest": {
"type": "object",
"properties": {
@@ -7240,6 +7617,57 @@
}
}
},
"internal_notification.NotificationResponse": {
"type": "object",
"properties": {
"created_at": {
"type": "integer"
},
"description": {
"type": "string"
},
"event_type": {
"type": "string"
},
"id": {
"type": "string"
},
"link": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {}
},
"methods": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"priority": {
"type": "string"
},
"schedule_at": {
"type": "integer"
},
"status": {
"type": "string"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
"updated_at": {
"type": "integer"
},
"user_id": {
"type": "string"
}
}
},
"notification.DeliveryChannel": {
"type": "string",
"enum": [
+269
View File
@@ -654,6 +654,15 @@ definitions:
example: reviewed
type: string
type: object
internal_notification.NotificationListResponse:
properties:
meta:
$ref: '#/definitions/response.Meta'
notifications:
items:
$ref: '#/definitions/internal_notification.NotificationResponse'
type: array
type: object
internal_notification.NotificationRequest:
properties:
channels:
@@ -681,6 +690,40 @@ definitions:
type:
$ref: '#/definitions/notification.NotificationType'
type: object
internal_notification.NotificationResponse:
properties:
created_at:
type: integer
description:
type: string
event_type:
type: string
id:
type: string
link:
type: string
metadata:
additionalProperties: {}
type: object
methods:
additionalProperties:
type: string
type: object
priority:
type: string
schedule_at:
type: integer
status:
type: string
title:
type: string
type:
type: string
updated_at:
type: integer
user_id:
type: string
type: object
notification.DeliveryChannel:
enum:
- push
@@ -2726,6 +2769,80 @@ paths:
tags:
- Admin-Inquiries
/admin/v1/notifications:
get:
consumes:
- application/json
description: Get notifications
parameters:
- description: Status filter
in: query
name: status
type: string
- description: Method filter
in: query
name: method
type: string
- description: Event type filter
in: query
name: event_type
type: string
- description: Type filter
in: query
name: type
type: string
- description: Recipient filter
in: query
name: recipient
type: string
- description: Limit results
in: query
name: limit
type: integer
- description: Offset results
in: query
name: offset
type: integer
- description: Sort field
in: query
name: sort_by
type: string
- description: Sort order
in: query
name: sort_order
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/internal_notification.NotificationListResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.APIResponse'
"403":
description: Forbidden
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get notifications
tags:
- Admin-Notification
post:
consumes:
- application/json
@@ -2752,9 +2869,86 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Create a new notification
tags:
- Admin-Notification
/admin/v1/notifications/my:
get:
consumes:
- application/json
description: Get notifications for the admin
parameters:
- description: Status filter
in: query
name: status
type: string
- description: Method filter
in: query
name: method
type: string
- description: Event type filter
in: query
name: event_type
type: string
- description: Type filter
in: query
name: type
type: string
- description: Recipient filter
in: query
name: recipient
type: string
- description: Limit results
in: query
name: limit
type: integer
- description: Offset results
in: query
name: offset
type: integer
- description: Sort field
in: query
name: sort_by
type: string
- description: Sort order
in: query
name: sort_order
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/internal_notification.NotificationListResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.APIResponse'
"403":
description: Forbidden
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get notifications for the admin
tags:
- Admin-Notification
/admin/v1/profile:
get:
consumes:
@@ -4324,6 +4518,81 @@ paths:
summary: Create new inquiry
tags:
- Inquiries
/api/v1/notifications/my:
get:
consumes:
- application/json
description: Get notifications for the user
parameters:
- description: Status filter
in: query
name: status
type: string
- description: Method filter
in: query
name: method
type: string
- description: Event type filter
in: query
name: event_type
type: string
- description: Type filter
in: query
name: type
type: string
- description: Recipient filter
in: query
name: recipient
type: string
- description: Limit results
in: query
name: limit
type: integer
- description: Offset results
in: query
name: offset
type: integer
- description: Sort field
in: query
name: sort_by
type: string
- description: Sort order
in: query
name: sort_order
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
$ref: '#/definitions/internal_notification.NotificationListResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.APIResponse'
"403":
description: Forbidden
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
security:
- BearerAuth: []
summary: Get notifications for the user
tags:
- Notification
/api/v1/profile:
get:
consumes: