(ctx context.Context, template database.Template, initiatorID uuid.UUID, receiverID uuid.UUID)
| 143 | } |
| 144 | |
| 145 | func (api *API) notifyTemplateDeleted(ctx context.Context, template database.Template, initiatorID uuid.UUID, receiverID uuid.UUID) { |
| 146 | initiator, err := api.Database.GetUserByID(ctx, initiatorID) |
| 147 | if err != nil { |
| 148 | api.Logger.Warn(ctx, "failed to fetch initiator for template deletion notification", slog.F("initiator_id", initiatorID), slog.Error(err)) |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | templateNameLabel := template.DisplayName |
| 153 | if templateNameLabel == "" { |
| 154 | templateNameLabel = template.Name |
| 155 | } |
| 156 | |
| 157 | // nolint:gocritic // Need notifier actor to enqueue notifications |
| 158 | if _, err := api.NotificationsEnqueuer.Enqueue(dbauthz.AsNotifier(ctx), receiverID, notifications.TemplateTemplateDeleted, |
| 159 | map[string]string{ |
| 160 | "name": templateNameLabel, |
| 161 | "initiator": initiator.Username, |
| 162 | }, "api-templates-delete", |
| 163 | // Associate this notification with all the related entities. |
| 164 | template.ID, template.OrganizationID, |
| 165 | ); err != nil { |
| 166 | api.Logger.Warn(ctx, "failed to notify of template deletion", slog.F("deleted_template_id", template.ID), slog.Error(err)) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // Create a new template in an organization. |
| 171 | // Returns a single template. |
no test coverage detected