Enhance Notification and User Models with New Fields and Update Swagger Documentation
- Added 'image' and 'link' fields to the NotificationRequest and NotificationResponse structures, improving the flexibility of notification content. - Updated the 'created_at', 'updated_at', and 'schedule_at' fields to use integer types for Unix timestamps, ensuring consistency in time handling. - Expanded the tender status enumeration to include 'closed', 'modified', 'suspended', and 'published', enhancing the representation of tender states. - Reflected these changes in the Swagger documentation, ensuring accurate API specifications for clients.
This commit is contained in:
@@ -15,6 +15,7 @@ type NotificationRequest struct {
|
||||
Title string `json:"title" valid:"required"`
|
||||
Description string `json:"description" valid:"required"`
|
||||
Link *string `json:"link" valid:"optional,url"`
|
||||
Image *string `json:"image" valid:"optional,url"`
|
||||
ScheduleAt int64 `json:"schedule_at" valid:"optional"`
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ func (h *NotificationHandler) Send(c echo.Context) error {
|
||||
}
|
||||
|
||||
// Send notification
|
||||
go h.service.Send(context.Background(), &req)
|
||||
h.service.Send(context.Background(), &req)
|
||||
|
||||
return response.Created(c, nil, "Notification sent successfully")
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
|
||||
"recipient": req.Recipient,
|
||||
"type": req.Type,
|
||||
"priority": req.Priority,
|
||||
"link": req.Link,
|
||||
"image": req.Image,
|
||||
})
|
||||
|
||||
if req.Target == TargetAudienceAllUsers || req.Target == TargetAudienceSpecificUsers {
|
||||
@@ -71,6 +73,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
|
||||
Type: string(req.Type),
|
||||
Priority: string(req.Priority),
|
||||
EventType: notification.EventTypePush,
|
||||
Link: *req.Link,
|
||||
Image: *req.Image,
|
||||
Metadata: map[string]any{
|
||||
"tender": strings.TrimSpace(req.Tender),
|
||||
},
|
||||
@@ -92,6 +96,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
|
||||
Type: string(req.Type),
|
||||
Priority: string(req.Priority),
|
||||
EventType: notification.EventTypeEmail,
|
||||
Link: *req.Link,
|
||||
Image: *req.Image,
|
||||
Metadata: map[string]any{
|
||||
"tender": strings.TrimSpace(req.Tender),
|
||||
},
|
||||
@@ -118,6 +124,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
|
||||
Type: string(req.Type),
|
||||
Priority: string(req.Priority),
|
||||
EventType: notification.EventTypePush,
|
||||
Link: *req.Link,
|
||||
Image: *req.Image,
|
||||
Methods: notification.NotificationMethods{
|
||||
Push: v,
|
||||
},
|
||||
@@ -138,6 +146,8 @@ func (s *notificationService) Send(ctx context.Context, req *NotificationRequest
|
||||
Type: string(req.Type),
|
||||
Priority: string(req.Priority),
|
||||
EventType: notification.EventTypeEmail,
|
||||
Link: *req.Link,
|
||||
Image: *req.Image,
|
||||
Methods: notification.NotificationMethods{
|
||||
Email: recipient.Email,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user