mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd): add new dispatch logic for coder inbox (#16764)
This PR is [resolving the dispatch part of Coder Inbocx](https://github.com/coder/internal/issues/403). Since the DB layer has been merged - we now want to insert notifications into Coder Inbox in parallel of the other delivery target. To do so, we push two messages instead of one using the `Enqueue` method.
This commit is contained in:
Generated
+2
-1
@@ -113,7 +113,8 @@ CREATE TYPE notification_message_status AS ENUM (
|
||||
|
||||
CREATE TYPE notification_method AS ENUM (
|
||||
'smtp',
|
||||
'webhook'
|
||||
'webhook',
|
||||
'inbox'
|
||||
);
|
||||
|
||||
CREATE TYPE notification_template_kind AS ENUM (
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
-- The migration is about an enum value change
|
||||
-- As we can not remove a value from an enum, we can let the down migration empty
|
||||
-- In order to avoid any failure, we use ADD VALUE IF NOT EXISTS to add the value
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TYPE notification_method ADD VALUE IF NOT EXISTS 'inbox';
|
||||
@@ -878,6 +878,7 @@ type NotificationMethod string
|
||||
const (
|
||||
NotificationMethodSmtp NotificationMethod = "smtp"
|
||||
NotificationMethodWebhook NotificationMethod = "webhook"
|
||||
NotificationMethodInbox NotificationMethod = "inbox"
|
||||
)
|
||||
|
||||
func (e *NotificationMethod) Scan(src interface{}) error {
|
||||
@@ -918,7 +919,8 @@ func (ns NullNotificationMethod) Value() (driver.Value, error) {
|
||||
func (e NotificationMethod) Valid() bool {
|
||||
switch e {
|
||||
case NotificationMethodSmtp,
|
||||
NotificationMethodWebhook:
|
||||
NotificationMethodWebhook,
|
||||
NotificationMethodInbox:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -928,6 +930,7 @@ func AllNotificationMethodValues() []NotificationMethod {
|
||||
return []NotificationMethod{
|
||||
NotificationMethodSmtp,
|
||||
NotificationMethodWebhook,
|
||||
NotificationMethodInbox,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3804,6 +3804,7 @@ SELECT
|
||||
nm.method,
|
||||
nm.attempt_count::int AS attempt_count,
|
||||
nm.queued_seconds::float AS queued_seconds,
|
||||
nm.targets,
|
||||
-- template
|
||||
nt.id AS template_id,
|
||||
nt.title_template,
|
||||
@@ -3829,6 +3830,7 @@ type AcquireNotificationMessagesRow struct {
|
||||
Method NotificationMethod `db:"method" json:"method"`
|
||||
AttemptCount int32 `db:"attempt_count" json:"attempt_count"`
|
||||
QueuedSeconds float64 `db:"queued_seconds" json:"queued_seconds"`
|
||||
Targets []uuid.UUID `db:"targets" json:"targets"`
|
||||
TemplateID uuid.UUID `db:"template_id" json:"template_id"`
|
||||
TitleTemplate string `db:"title_template" json:"title_template"`
|
||||
BodyTemplate string `db:"body_template" json:"body_template"`
|
||||
@@ -3865,6 +3867,7 @@ func (q *sqlQuerier) AcquireNotificationMessages(ctx context.Context, arg Acquir
|
||||
&i.Method,
|
||||
&i.AttemptCount,
|
||||
&i.QueuedSeconds,
|
||||
pq.Array(&i.Targets),
|
||||
&i.TemplateID,
|
||||
&i.TitleTemplate,
|
||||
&i.BodyTemplate,
|
||||
|
||||
@@ -84,6 +84,7 @@ SELECT
|
||||
nm.method,
|
||||
nm.attempt_count::int AS attempt_count,
|
||||
nm.queued_seconds::float AS queued_seconds,
|
||||
nm.targets,
|
||||
-- template
|
||||
nt.id AS template_id,
|
||||
nt.title_template,
|
||||
|
||||
Reference in New Issue
Block a user