diff --git a/backend/src/models/notification.go b/backend/src/models/notification.go index e179030d..3a3b76a6 100644 --- a/backend/src/models/notification.go +++ b/backend/src/models/notification.go @@ -73,6 +73,10 @@ type Notification struct { Date time.Time `json:"date" bson:"date"` + // Optional human-friendly name of the target entity. + // Useful for deleted entities (company/speaker) that no longer exist. + Name string `json:"name,omitempty" bson:"name,omitempty"` + // Signature is used to verify if 2 notifications are equal Signature string `json:"signature" bson:"signature"` } diff --git a/backend/src/mongodb/notification.go b/backend/src/mongodb/notification.go index b82ebe1c..167ba7e7 100644 --- a/backend/src/mongodb/notification.go +++ b/backend/src/mongodb/notification.go @@ -143,6 +143,8 @@ type CreateNotificationData struct { Company *primitive.ObjectID Meeting *primitive.ObjectID Session *primitive.ObjectID + // Optional human-friendly name of the target entity + Name string } // NotifyMember adds a notification to a member @@ -158,6 +160,7 @@ func (n *NotificationsType) NotifyMember(memberID primitive.ObjectID, data Creat Company: data.Company, Meeting: data.Meeting, Session: data.Session, + Name: data.Name, } if err := notification.Validate(); err != nil { @@ -181,6 +184,7 @@ func (n *NotificationsType) NotifyMember(memberID primitive.ObjectID, data Creat "company": data.Company, "meeting": data.Meeting, "session": data.Session, + "name": data.Name, "signature": signature, "date": time.Now().UTC(), } @@ -253,6 +257,8 @@ func (n *NotificationsType) GetMemberNotifications(memberID primitive.ObjectID) "signature": notification.Signature, "member": notification.Member.Hex(), "date": notification.Date.Format(time.RFC3339), + // include optional human-friendly name for deleted entities + "name": notification.Name, } if notification.Post != nil { diff --git a/backend/src/router/company.go b/backend/src/router/company.go index 834ac32e..2b67bb93 100644 --- a/backend/src/router/company.go +++ b/backend/src/router/company.go @@ -731,6 +731,7 @@ func deleteCompany(w http.ResponseWriter, r *http.Request) { mongodb.Notifications.Notify(credentials.ID, mongodb.CreateNotificationData{ Kind: models.NotificationKindDeleted, Company: &deletedCompany.ID, + Name: deletedCompany.Name, }) } } diff --git a/backend/src/router/speaker.go b/backend/src/router/speaker.go index ed19f2e3..7e8c4be3 100644 --- a/backend/src/router/speaker.go +++ b/backend/src/router/speaker.go @@ -57,6 +57,15 @@ func deleteSpeaker(w http.ResponseWriter, r *http.Request) { } json.NewEncoder(w).Encode(deletedSpeaker) + + // notify + if credentials, ok := r.Context().Value(credentialsKey).(models.AuthorizationCredentials); ok { + mongodb.Notifications.Notify(credentials.ID, mongodb.CreateNotificationData{ + Kind: models.NotificationKindDeleted, + Speaker: &deletedSpeaker.ID, + Name: deletedSpeaker.Name, + }) + } } func getSpeakerPublic(w http.ResponseWriter, r *http.Request) { diff --git a/frontend/src/api/companies.ts b/frontend/src/api/companies.ts index 15f22a76..a63c0f4a 100644 --- a/frontend/src/api/companies.ts +++ b/frontend/src/api/companies.ts @@ -91,6 +91,9 @@ export const updateRepresentativeOrder = ( export const uploadCompanyInternalImage = (id: string, data: FormData) => instance.post(`/companies/${id}/image/internal`, data); +export const deleteCompany = (id: string) => + instance.delete(`/companies/${id}`); + export interface GenerateCompanyContractData { language: string; eventId: number; diff --git a/frontend/src/api/speakers.ts b/frontend/src/api/speakers.ts index 155b234f..2558ac44 100644 --- a/frontend/src/api/speakers.ts +++ b/frontend/src/api/speakers.ts @@ -50,3 +50,6 @@ export const createSpeaker = (data: CreateSpeakerData) => export const uploadSpeakerInternalImage = (id: string, data: FormData) => instance.post(`/speakers/${id}/image/internal`, data); + +export const deleteSpeaker = (id: string) => + instance.delete(`/speakers/${id}`); diff --git a/frontend/src/components/cards/CompanyCard.vue b/frontend/src/components/cards/CompanyCard.vue index 846e078e..571a0715 100644 --- a/frontend/src/components/cards/CompanyCard.vue +++ b/frontend/src/components/cards/CompanyCard.vue @@ -1,17 +1,47 @@