Commit Graph

43 Commits

Author SHA1 Message Date
d2419c89ac feat: add tool to send a test notification (#16611)
Relates to https://github.com/coder/coder/issues/16463

Adds a CLI command, and API endpoint, to trigger a test notification for
administrators of a deployment.
2025-02-19 13:08:38 +00:00
dbad69dbd9 chore: add workspace oom/ood notification templates (#16250) 2025-02-04 19:25:18 +00:00
c069563af1 test: fix use of t.Logf where t.Log would suffice (#16328) 2025-01-29 14:35:04 +00:00
009069cd47 feat: allow notification templates to be disabled by default (#16093)
Change as part of https://github.com/coder/coder/pull/16071

It has been decided that we want to be able to have some notification
templates be disabled _by default_
https://github.com/coder/coder/pull/16071#issuecomment-2580757061.

This adds a new column (`enabled_by_default`) to
`notification_templates` that defaults to `TRUE`. It also modifies the
`inhibit_enqueue_if_disabled` function to reject notifications for
templates that have `enabled_by_default = FALSE` with the user not
explicitly enabling it.
2025-01-13 15:01:47 +00:00
7b88776403 chore(testutil): add testutil.GoleakOptions (#16070)
- Adds `testutil.GoleakOptions` and consolidates existing options to
this location
- Pre-emptively adds required ignore for this Dependabot PR to pass CI
https://github.com/coder/coder/pull/16066
2025-01-08 15:38:37 +00:00
f3fe3bc785 feat: notify on workspace update (#15979)
Relates to https://github.com/coder/coder/issues/15845

When the `/workspace/<name>/builds` endpoint is hit, we check if the
requested template version is different to the previously used template
version. If these values differ, we can assume that the workspace has
been manually updated and send the appropriate notification. Automatic
updates happen in the lifecycle executor and bypasses this endpoint
entirely.
2025-01-02 12:19:34 +00:00
f0e81ab455 feat: notify on workspace creation (#15934) 2024-12-20 13:53:10 +00:00
6ed76921dd chore: fix windows postgres tests (#15593)
Patches tests that caused Windows Postgres CI in
https://github.com/coder/coder/pull/15520 to consistently fail.

I tested this by temporarily adding Postgres Windows CI to this PR.
However, I reverted those changes to merge them with
https://github.com/coder/coder/pull/15520. For reference, here's [a
passing CI
run](https://github.com/coder/coder/actions/runs/11918816662/job/33219786238)
from an earlier commit.

**Note:** Although Windows tests now pass, they remain quite flaky. I
recommend running Postgres Windows CI to gather data on these flakes,
but I don’t think it should be a required job just yet.
2024-11-20 13:30:31 +01:00
576e1f48fe feat!: allow disabling notifications (#15509)
Resolves https://github.com/coder/coder/issues/15513

Disables notifications when both `$CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT` and `$CODER_EMAIL_SMARTHOST` are unset.

Breaking change: `$CODER_EMAIL_SMARTHOST` is no longer set by default as `localhost:587`, meaning any deployments that make use of this default value will need to add it back.

---------

Co-authored-by: Danny Kopping <danny@coder.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2024-11-19 15:05:12 +00:00
5861e516b9 chore: add standard test logger ignoring db canceled (#15556)
Refactors our use of `slogtest` to instantiate a "standard logger" across most of our tests.  This standard logger incorporates https://github.com/coder/slog/pull/217 to also ignore database query canceled errors by default, which are a source of low-severity flakes.

Any test that has set non-default `slogtest.Options` is left alone. In particular, `coderdtest` defaults to ignoring all errors. We might consider revisiting that decision now that we have better tools to target the really common flaky Error logs on shutdown.
2024-11-18 14:09:22 +04:00
330acd1270 chore: create ResourceNotificationMessage and AsNotifier (#15301)
Closes https://github.com/coder/coder/issues/15213

This PR enables sending notifications without requiring the auth system
context, instead using a new auth notifier context.
2024-10-31 17:01:51 +00:00
6e54bd9183 test(coderd/notifications): fix data race in tests and smpttest (#15304) 2024-10-31 15:48:49 +02:00
095c9797c9 feat: notify users on template deprecation (#15195)
Closes https://github.com/coder/coder/issues/15117

Notify users when a template has been deprecated.
2024-10-24 13:12:12 +01:00
297089e944 feat(coderd): add company logo when available for email notifications (#14935)
This PR aims to close #14253 

We keep the default behavior using the Coder logo if there's no logo
set.
Otherwise we want to use the logo based on the URL set in appearance.

---------

Co-authored-by: defelmnq <yvincent@coder.com>
2024-10-22 14:06:19 +02:00
23f61c68b4 fix: urlencode email in reset password link (#15167)
Fixes https://github.com/coder/coder/issues/15151

This runs `urlencode` (provided by `text/template`) on the email address
in the link. This ensures the link will work if a user has an email in
the form `user+label@example.com`.
2024-10-21 16:09:59 +01:00
29099d4727 chore: refactor notifier to use quartz.TickerFunc (#15134)
In investigating https://github.com/coder/internal/issues/109 I noticed many of the notification tests are still using `time.Sleep` and `require.Eventually`. This is an initial effort to start converting these to Quartz.

One product change is to switch the `notifier` to use a `TickerFunc` instead of a normal Ticker, since it allows the test to assert that a batch process is complete via the Quartz `Mock` clock.  This does introduce one slight behavioral change in that the notifier waits the fetch interval before processing its first batch.  In practice, this is inconsequential: no one will notice if we send notifications immediately on startup, or just a little later.

But, it does make a difference to some tests, which are fixed up here.
2024-10-21 12:07:19 +04:00
8c8bd3141f chore: stop creating coderd for notification unit tests (#15133)
A bunch of notification tests create a whole `coderd`, when all they use is the database and logger.  This makes the tests more expensive to run, and pollutes the test logs with a bunch of stuff that doesn't matter (e.g. tailnet).
2024-10-21 10:39:37 +04:00
fac77f956e fix(coderd/notifications): simplify TemplateWorkspaceManualBuildFailed (#15067)
This PR closes #15065.

As advised by @mtojek, a template's display name may be set to "", which
is not useful in an email notification. We'd like to provide a friendly
name for the template, but it also needs to be identifiable.

As such, we fall back to template.Name in the case that the template's
display name is empty.
2024-10-15 21:02:02 +02:00
208ed1efd7 chore(coderd/notifications): expand golden file testing for notifications (#15032)
This PR aims to close https://github.com/coder/coder/issues/14913.

It expands the golden files for the notifier to include the entire
payload serialised as JSON.
2024-10-14 12:34:32 +00:00
9d02269191 feat(coderd/notifications): improve notification format consistency (#14967)
This Pull request addresses the more trivial items in
https://github.com/coder/coder/issues/14893.
These were simple formatting changes that I was able to fix despite
limited context.

Some more changes are required for which I will have to dig a bit deeper
into how the template contexts are populated. I'm happy to add those to
this PR or create a subsequent PR.
2024-10-09 17:31:12 -05:00
4369f2b4b5 feat: implement api for "forgot password?" flow (#14915)
Relates to https://github.com/coder/coder/issues/14232

This implements two endpoints (names subject to change):
- `/api/v2/users/otp/request`
- `/api/v2/users/otp/change-password`
2024-10-04 11:53:25 +01:00
0aa84b18a1 feat: expose Markdown fields in webhook payload (#14931)
Fixes: https://github.com/coder/coder/issues/14930
2024-10-02 15:38:22 +02:00
11f7b1b3f5 chore: remove notifications experiment (#14869)
Notifications have proved stable in the [mainline release of
v2.15](https://github.com/coder/coder/releases/tag/v2.15.0), and in
preparation for v2.16 we're moving this to stable.
2024-10-01 13:43:47 +00:00
20a3801600 fix: use floats in report template (#14714) 2024-09-18 11:26:34 +00:00
6de59371ea feat: notifications: report failed workspace builds (#14571) 2024-09-18 09:11:44 +02:00
e6d8f674ad feat: generate golden files for notification templates (#14537) 2024-09-04 18:26:57 +02:00
f24cb5cc96 fix: prevent test flakiness (#14467)
Signed-off-by: Danny Kopping <danny@coder.com>
2024-08-28 16:33:27 +02:00
47f2c7d683 feat: notify about manual failed builds (#14419) 2024-08-27 14:35:28 +00:00
a4d785dec5 chore: use idiomatic test setup in notification tests (#14416) 2024-08-23 16:29:27 +02:00
c818b4ddd4 feat: add notification for suspended/activated account (#14367)
* migrations

* notify

* fix

* TestNotifyUserSuspended

* TestNotifyUserReactivate

* post merge

* fix escape

* TestNotificationTemplatesCanRender

* links and events

* notifyEnq

* findUserAdmins

* notifyUserStatusChanged

* go build

* your and admin

* tests

* refactor

* 247

* Danny's review
2024-08-22 13:52:25 +02:00
9c8c6a952d feat: add notification deduplication trigger (#14172) 2024-08-21 11:18:03 +02:00
10327fb3a9 fix(coderd): humanize duration on notifications (#14333) 2024-08-19 15:49:47 -03:00
6f1951e1c8 feat: add template delete notification (#14250) 2024-08-14 14:22:43 -03:00
27b8f201a4 refactor: refactor notification email template (#14208) 2024-08-09 11:25:19 -03:00
c6076d2d0d chore: improve notification template tests' resilience (#14196) 2024-08-07 11:33:26 +02:00
58428aafce fix: allow all users to read system notification templates (#14181) 2024-08-06 15:37:49 +02:00
e164b1e71c feat: add notification preferences database & audit support (#14100) 2024-08-05 16:18:45 +02:00
58b810fb0a fix: fix dormancy notifications (#14029) 2024-07-29 11:20:04 -03:00
d488853393 fix: notifications: use username in workspace URLs (#14011) 2024-07-25 12:02:24 +02:00
b2dab3308d feat: implement observability of notifications subsystem (#13799) 2024-07-11 10:57:49 +02:00
bf392ffea4 feat: add killswitch for notifications (#13794) 2024-07-10 16:15:06 +02:00
542fff7df0 chore: improve notifications tests (#13863) 2024-07-10 15:25:23 +02:00
bdd2caf95d feat: implement thin vertical slice of system-generated notifications (#13537) 2024-07-08 15:38:50 +02:00