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": [