From a796a3f333442d1929066d6dbec4344eddb118d3 Mon Sep 17 00:00:00 2001 From: lareii Date: Wed, 18 Sep 2024 22:28:00 +0300 Subject: [PATCH] chore(server): replace content field with typeid --- server/models/notifications.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/models/notifications.go b/server/models/notifications.go index 52d9f71..036f35e 100644 --- a/server/models/notifications.go +++ b/server/models/notifications.go @@ -15,9 +15,9 @@ type Notification struct { ID primitive.ObjectID `bson:"_id" json:"id"` CreatedAt primitive.Timestamp `bson:"created_at" json:"created_at"` RecipientID primitive.ObjectID `bson:"recipient_id" json:"recipient_id"` - Content string `bson:"content" json:"content"` + Type string `bson:"type" json:"type"` + TypeID primitive.ObjectID `bson:"type_id" json:"type_id"` Read bool `bson:"read" json:"read"` - Link string `bson:"link" json:"link"` } func GetNotifications(limit, offset int64, userID primitive.ObjectID) ([]Notification, error) { @@ -41,15 +41,15 @@ func GetNotifications(limit, offset int64, userID primitive.ObjectID) ([]Notific return notifications, nil } -func CreateNotification(notification Notification) (Notification, error) { +func CreateNotification(notification Notification) error { notification.ID = primitive.NewObjectID() notification.CreatedAt = primitive.Timestamp{T: uint32(time.Now().Unix())} notification.Read = false _, err := database.Notifications.InsertOne(context.Background(), notification) if err != nil { - return Notification{}, err + return fmt.Errorf("error creating notification: %v", err) } - return notification, nil + return nil }