Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b9098a

Browse files
committed
Add dispatch methods endpoint
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent7bb1ee0 commit3b9098a

File tree

8 files changed

+157
-0
lines changed

8 files changed

+157
-0
lines changed

‎coderd/apidoc/docs.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,7 @@ func New(options *Options) *API {
12581258
r.Route("/templates",func(r chi.Router) {
12591259
r.Get("/system",api.systemNotificationTemplates)
12601260
})
1261+
r.Get("/dispatch-methods",api.notificationDispatchMethods)
12611262
})
12621263
})
12631264

‎coderd/notifications.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ func (api *API) systemNotificationTemplates(rw http.ResponseWriter, r *http.Requ
144144
httpapi.Write(r.Context(),rw,http.StatusOK,out)
145145
}
146146

147+
// @Summary Get notification dispatch methods
148+
// @ID get-notification-dispatch-methods
149+
// @Produce json
150+
// @Tags Notifications
151+
// @Success 200 {array} codersdk.NotificationMethodsResponse
152+
// @Router /notifications/dispatch-methods [get]
153+
func (api*API)notificationDispatchMethods(rw http.ResponseWriter,r*http.Request) {
154+
varmethods []string
155+
for_,nm:=rangedatabase.AllNotificationMethodValues() {
156+
methods=append(methods,string(nm))
157+
}
158+
159+
httpapi.Write(r.Context(),rw,http.StatusOK, codersdk.NotificationMethodsResponse{
160+
AvailableNotificationMethods:methods,
161+
DefaultNotificationMethod:api.DeploymentValues.Notifications.Method.Value(),
162+
})
163+
}
164+
147165
// @Summary Get user notification preferences
148166
// @ID get-user-notification-preferences
149167
// @Security CoderSessionToken

‎codersdk/notifications.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ type NotificationTemplate struct {
2727
Kindstring`json:"kind"`
2828
}
2929

30+
typeNotificationMethodsResponsestruct {
31+
AvailableNotificationMethods []string`json:"available"`
32+
DefaultNotificationMethodstring`json:"default"`
33+
}
34+
3035
typeNotificationPreferencestruct {
3136
NotificationTemplateID uuid.UUID`json:"id" format:"uuid"`
3237
Disabledbool`json:"disabled"`

‎docs/api/notifications.md

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/api/schemas.md

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/api/typesGenerated.ts

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp