fix: notifications: use username in workspace URLs (#14011)

This commit is contained in:
Marcin Tojek
2024-07-25 12:02:24 +02:00
committed by GitHub
parent 88bc491778
commit d488853393
9 changed files with 29 additions and 13 deletions
+1
View File
@@ -1929,6 +1929,7 @@ func (q *FakeQuerier) FetchNewMessageMetadata(_ context.Context, arg database.Fe
return database.FetchNewMessageMetadataRow{
UserEmail: user.Email,
UserName: userName,
UserUsername: user.Username,
NotificationName: "Some notification",
Actions: actions,
UserID: arg.UserID,
@@ -0,0 +1,3 @@
UPDATE notification_templates
SET
actions = REPLACE(actions::text, '@{{.UserUsername}}', '@{{.UserName}}')::jsonb;
@@ -0,0 +1,3 @@
UPDATE notification_templates
SET
actions = REPLACE(actions::text, '@{{.UserName}}', '@{{.UserUsername}}')::jsonb;
+4 -1
View File
@@ -3546,7 +3546,8 @@ SELECT nt.name AS notificatio
nt.actions AS actions,
u.id AS user_id,
u.email AS user_email,
COALESCE(NULLIF(u.name, ''), NULLIF(u.username, ''))::text AS user_name
COALESCE(NULLIF(u.name, ''), NULLIF(u.username, ''))::text AS user_name,
COALESCE(u.username, '') AS user_username
FROM notification_templates nt,
users u
WHERE nt.id = $1
@@ -3564,6 +3565,7 @@ type FetchNewMessageMetadataRow struct {
UserID uuid.UUID `db:"user_id" json:"user_id"`
UserEmail string `db:"user_email" json:"user_email"`
UserName string `db:"user_name" json:"user_name"`
UserUsername string `db:"user_username" json:"user_username"`
}
// This is used to build up the notification_message's JSON payload.
@@ -3576,6 +3578,7 @@ func (q *sqlQuerier) FetchNewMessageMetadata(ctx context.Context, arg FetchNewMe
&i.UserID,
&i.UserEmail,
&i.UserName,
&i.UserUsername,
)
return i, err
}
+2 -1
View File
@@ -4,7 +4,8 @@ SELECT nt.name AS notificatio
nt.actions AS actions,
u.id AS user_id,
u.email AS user_email,
COALESCE(NULLIF(u.name, ''), NULLIF(u.username, ''))::text AS user_name
COALESCE(NULLIF(u.name, ''), NULLIF(u.username, ''))::text AS user_name,
COALESCE(u.username, '') AS user_username
FROM notification_templates nt,
users u
WHERE nt.id = @notification_template_id