Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions coderd/database/dbauthz/dbauthz.go
Original file line number Diff line number Diff line change
Expand Up @@ -5437,17 +5437,6 @@ func (q *querier) GetUserStatusCounts(ctx context.Context, arg database.GetUserS
return q.db.GetUserStatusCounts(ctx, arg)
}

func (q *querier) GetUserTaskNotificationAlertDismissed(ctx context.Context, userID uuid.UUID) (bool, error) {
user, err := q.db.GetUserByID(ctx, userID)
if err != nil {
return false, err
}
if err := q.authorizeContext(ctx, policy.ActionReadPersonal, user); err != nil {
return false, err
}
return q.db.GetUserTaskNotificationAlertDismissed(ctx, userID)
}

func (q *querier) GetUserThinkingDisplayMode(ctx context.Context, userID uuid.UUID) (string, error) {
user, err := q.db.GetUserByID(ctx, userID)
if err != nil {
Expand Down Expand Up @@ -8610,17 +8599,6 @@ func (q *querier) UpdateUserStatus(ctx context.Context, arg database.UpdateUserS
return updateWithReturn(q.log, q.auth, fetch, q.db.UpdateUserStatus)(ctx, arg)
}

func (q *querier) UpdateUserTaskNotificationAlertDismissed(ctx context.Context, arg database.UpdateUserTaskNotificationAlertDismissedParams) (bool, error) {
user, err := q.db.GetUserByID(ctx, arg.UserID)
if err != nil {
return false, err
}
if err := q.authorizeContext(ctx, policy.ActionUpdatePersonal, user); err != nil {
return false, err
}
return q.db.UpdateUserTaskNotificationAlertDismissed(ctx, arg)
}

func (q *querier) UpdateUserTerminalFont(ctx context.Context, arg database.UpdateUserTerminalFontParams) (database.UserConfig, error) {
u, err := q.db.GetUserByID(ctx, arg.UserID)
if err != nil {
Expand Down
16 changes: 0 additions & 16 deletions coderd/database/dbauthz/dbauthz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"maps"
"net"
"reflect"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -3226,12 +3225,6 @@ func (s *MethodTestSuite) TestUser() {
dbm.EXPECT().UpdateUserThemeDark(gomock.Any(), arg).Return(uc, nil).AnyTimes()
check.Args(arg).Asserts(u, policy.ActionUpdatePersonal).Returns(uc)
}))
s.Run("GetUserTaskNotificationAlertDismissed", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
u := testutil.Fake(s.T(), faker, database.User{})
dbm.EXPECT().GetUserByID(gomock.Any(), u.ID).Return(u, nil).AnyTimes()
dbm.EXPECT().GetUserTaskNotificationAlertDismissed(gomock.Any(), u.ID).Return(false, nil).AnyTimes()
check.Args(u.ID).Asserts(u, policy.ActionReadPersonal).Returns(false)
}))
s.Run("GetUserChatCustomPrompt", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
u := testutil.Fake(s.T(), faker, database.User{})
dbm.EXPECT().GetUserByID(gomock.Any(), u.ID).Return(u, nil).AnyTimes()
Expand Down Expand Up @@ -3410,15 +3403,6 @@ func (s *MethodTestSuite) TestUser() {
dbm.EXPECT().DeleteUserChatCompactionThreshold(gomock.Any(), arg).Return(nil).AnyTimes()
check.Args(arg).Asserts(u, policy.ActionUpdatePersonal)
}))
s.Run("UpdateUserTaskNotificationAlertDismissed", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
user := testutil.Fake(s.T(), faker, database.User{})
userConfig := database.UserConfig{UserID: user.ID, Key: "task_notification_alert_dismissed", Value: "false"}
userConfigValue, _ := strconv.ParseBool(userConfig.Value)
arg := database.UpdateUserTaskNotificationAlertDismissedParams{UserID: user.ID, TaskNotificationAlertDismissed: userConfigValue}
dbm.EXPECT().GetUserByID(gomock.Any(), user.ID).Return(user, nil).AnyTimes()
dbm.EXPECT().UpdateUserTaskNotificationAlertDismissed(gomock.Any(), arg).Return(false, nil).AnyTimes()
check.Args(arg).Asserts(user, policy.ActionUpdatePersonal).Returns(userConfigValue)
}))
s.Run("UpdateUserStatus", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
u := testutil.Fake(s.T(), faker, database.User{})
arg := database.UpdateUserStatusParams{ID: u.ID, Status: u.Status, UpdatedAt: u.UpdatedAt}
Expand Down
16 changes: 0 additions & 16 deletions coderd/database/dbmetrics/querymetrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions coderd/database/dbmock/dbmock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- Restore task notification templates. Inbox notification history deleted
-- by the cascade is not recoverable.
INSERT INTO notification_templates (
id, name, title_template, body_template, actions, "group", method, kind, enabled_by_default
) VALUES (
'bd4b7168-d05e-4e19-ad0f-3593b77aa90f',
'Task Working',
E'Task ''{{.Labels.workspace}}'' is working',
E'The task ''{{.Labels.task}}'' transitioned to a working state.',
'[{"label": "View task", "url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.workspace}}"}, {"label": "View workspace", "url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"}]'::jsonb,
'Task Events',
NULL,
'system'::notification_template_kind,
false
), (
'd4a6271c-cced-4ed0-84ad-afd02a9c7799',
'Task Idle',
E'Task ''{{.Labels.workspace}}'' is idle',
E'The task ''{{.Labels.task}}'' is idle and ready for input.',
'[{"label": "View task", "url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.workspace}}"}, {"label": "View workspace", "url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"}]'::jsonb,
'Task Events',
NULL,
'system'::notification_template_kind,
false
), (
'8c5a4d12-9f7e-4b3a-a1c8-6e4f2d9b5a7c',
'Task Completed',
E'Task ''{{.Labels.workspace}}'' completed',
E'The task ''{{.Labels.task}}'' has completed successfully.',
'[{"label": "View task", "url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.workspace}}"}, {"label": "View workspace", "url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"}]'::jsonb,
'Task Events',
NULL,
'system'::notification_template_kind,
false
), (
'3b7e8f1a-4c2d-49a6-b5e9-7f3a1c8d6b4e',
'Task Failed',
E'Task ''{{.Labels.workspace}}'' failed',
E'The task ''{{.Labels.task}}'' has failed. Check the logs for more details.',
'[{"label": "View task", "url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.workspace}}"}, {"label": "View workspace", "url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"}]'::jsonb,
'Task Events',
NULL,
'system'::notification_template_kind,
false
), (
'2a74f3d3-ab09-4123-a4a5-ca238f4f65a1',
'Task Paused',
E'Task ''{{.Labels.task}}'' is paused',
E'The task ''{{.Labels.task}}'' was paused ({{.Labels.pause_reason}}).',
'[{"label": "View task", "url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.task_id}}"}, {"label": "View workspace", "url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"}]'::jsonb,
'Task Events',
NULL,
'system'::notification_template_kind,
true
), (
'843ee9c3-a8fb-4846-afa9-977bec578649',
'Task Resumed',
E'Task ''{{.Labels.task}}'' has resumed',
E'The task ''{{.Labels.task}}'' has resumed.',
'[{"label": "View task", "url": "{{base_url}}/tasks/{{.UserUsername}}/{{.Labels.task_id}}"}, {"label": "View workspace", "url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}"}]'::jsonb,
'Task Events',
NULL,
'system'::notification_template_kind,
true
);
15 changes: 15 additions & 0 deletions coderd/database/migrations/000592_remove_task_notifications.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Delete task notification templates and preferences. The delete cascades
-- to inbox_notifications and notification_messages: historical task
-- notifications are intentionally removed with the feature.
DELETE FROM notification_templates
WHERE id IN (
'bd4b7168-d05e-4e19-ad0f-3593b77aa90f', -- Task Working
'd4a6271c-cced-4ed0-84ad-afd02a9c7799', -- Task Idle
'8c5a4d12-9f7e-4b3a-a1c8-6e4f2d9b5a7c', -- Task Completed
'3b7e8f1a-4c2d-49a6-b5e9-7f3a1c8d6b4e', -- Task Failed
'2a74f3d3-ab09-4123-a4a5-ca238f4f65a1', -- Task Paused
'843ee9c3-a8fb-4846-afa9-977bec578649' -- Task Resumed
);

DELETE FROM user_configs
WHERE key = 'preference_task_notification_alert_dismissed';
2 changes: 0 additions & 2 deletions coderd/database/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 0 additions & 44 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions coderd/database/queries/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,6 @@ END
WHERE user_configs.user_id = @user_id
AND user_configs.key = 'chat_debug_logging_enabled';

-- name: GetUserTaskNotificationAlertDismissed :one
SELECT
value::boolean as task_notification_alert_dismissed
FROM
user_configs
WHERE
user_id = @user_id
AND key = 'preference_task_notification_alert_dismissed';

-- name: UpdateUserTaskNotificationAlertDismissed :one
INSERT INTO
user_configs (user_id, key, value)
VALUES
(@user_id, 'preference_task_notification_alert_dismissed', (@task_notification_alert_dismissed::boolean)::text)
ON CONFLICT
ON CONSTRAINT user_configs_pkey
DO UPDATE
SET
value = @task_notification_alert_dismissed
WHERE user_configs.user_id = @user_id
AND user_configs.key = 'preference_task_notification_alert_dismissed'
RETURNING value::boolean AS task_notification_alert_dismissed;

-- name: GetUserThinkingDisplayMode :one
SELECT
value AS thinking_display_mode
Expand Down
10 changes: 0 additions & 10 deletions coderd/notifications/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ var (
TemplateCustomNotification = uuid.MustParse("39b1e189-c857-4b0c-877a-511144c18516")
)

// Task-related events.
var (
TemplateTaskWorking = uuid.MustParse("bd4b7168-d05e-4e19-ad0f-3593b77aa90f")
TemplateTaskIdle = uuid.MustParse("d4a6271c-cced-4ed0-84ad-afd02a9c7799")
TemplateTaskCompleted = uuid.MustParse("8c5a4d12-9f7e-4b3a-a1c8-6e4f2d9b5a7c")
TemplateTaskFailed = uuid.MustParse("3b7e8f1a-4c2d-49a6-b5e9-7f3a1c8d6b4e")
TemplateTaskPaused = uuid.MustParse("2a74f3d3-ab09-4123-a4a5-ca238f4f65a1")
TemplateTaskResumed = uuid.MustParse("843ee9c3-a8fb-4846-afa9-977bec578649")
)

// Chat-related events.
var (
TemplateChatAutoArchiveDigest = uuid.MustParse("764031be-4863-4220-867b-6ce1a1b7a5f5")
Expand Down
Loading
Loading