Refactor Notification Management and Enhance Customer Features
- Updated the notification handling logic to utilize a new SDK for sending notifications, improving the flexibility and scalability of the notification system. - Introduced new methods in the notification service for sending notifications to users and customers based on various target audience types, enhancing the notification delivery capabilities. - Added a new endpoint to assign companies to a customer, improving customer management functionalities. - Refactored the customer entity and forms to replace 'CompanyIDs' with 'Companies', ensuring consistency across the data model. - Enhanced API documentation with Swagger comments for the new endpoint and updated notification structures, ensuring clarity for API consumers.
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
package notification
|
||||
|
||||
import (
|
||||
"tm/pkg/mongo"
|
||||
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// NotificationType represents the type of notification
|
||||
type NotificationType string
|
||||
|
||||
@@ -65,46 +59,8 @@ const (
|
||||
TargetAudienceSpecificCustomer TargetAudienceType = "specific_customer"
|
||||
)
|
||||
|
||||
// Notification represents a notification entity
|
||||
type Notification struct {
|
||||
mongo.Model `bson:",inline"`
|
||||
Recipient []string `bson:"recipients"`
|
||||
Tender bson.ObjectID `bson:"tender"`
|
||||
Channels []DeliveryChannel `bson:"channels"`
|
||||
Type NotificationType `bson:"type"`
|
||||
Priority NotificationPriority `bson:"priority"`
|
||||
Status NotificationStatus `bson:"status"`
|
||||
Target TargetAudienceType `bson:"target"`
|
||||
Title string `bson:"title"`
|
||||
Description string `bson:"description"`
|
||||
Link *string `bson:"link"`
|
||||
Schedule Schedule `bson:"schedule"`
|
||||
}
|
||||
|
||||
type Schedule struct {
|
||||
Time int64 `bson:"time"`
|
||||
}
|
||||
|
||||
func (n *Notification) SetID(id string) {
|
||||
n.ID, _ = bson.ObjectIDFromHex(id)
|
||||
}
|
||||
|
||||
func (n *Notification) GetID() string {
|
||||
return n.ID.Hex()
|
||||
}
|
||||
|
||||
func (n *Notification) SetCreatedAt(timestamp int64) {
|
||||
n.CreatedAt = timestamp
|
||||
}
|
||||
|
||||
func (n *Notification) SetUpdatedAt(timestamp int64) {
|
||||
n.UpdatedAt = timestamp
|
||||
}
|
||||
|
||||
func (n *Notification) GetCreatedAt() int64 {
|
||||
return n.CreatedAt
|
||||
}
|
||||
|
||||
func (n *Notification) GetUpdatedAt() int64 {
|
||||
return n.UpdatedAt
|
||||
type notificationRecipient struct {
|
||||
UserID string
|
||||
Email string
|
||||
DeviceTokens []string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user