MCPcopy Index your code
hub / github.com/coder/coder / notifyTemplateDeleted

Method notifyTemplateDeleted

coderd/templates.go:145–168  ·  view source on GitHub ↗
(ctx context.Context, template database.Template, initiatorID uuid.UUID, receiverID uuid.UUID)

Source from the content-addressed store, hash-verified

143}
144
145func (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.

Callers 1

deleteTemplateMethod · 0.95

Calls 4

AsNotifierFunction · 0.92
GetUserByIDMethod · 0.65
EnqueueMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected