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

Commit0aef037

Browse files
committed
make lint/fmt
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent5651cad commit0aef037

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

‎coderd/notifications.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (api *API) putUserNotificationPreferences(rw http.ResponseWriter, r *http.R
219219

220220
updated,err:=api.Database.UpdateUserNotificationPreferences(ctx,input)
221221
iferr!=nil {
222-
logger.Error(ctx,"failed to update",slog.Error(err))
222+
logger.Error(ctx,"failed to update preferences",slog.Error(err))
223223

224224
httpapi.Write(r.Context(),rw,http.StatusInternalServerError, codersdk.Response{
225225
Message:"Failed to update user notifications preferences.",
@@ -228,11 +228,11 @@ func (api *API) putUserNotificationPreferences(rw http.ResponseWriter, r *http.R
228228
return
229229
}
230230

231-
logger.Info(ctx,"updated",slog.F("count",updated))
231+
logger.Info(ctx,"updated preferences",slog.F("count",updated))
232232

233233
userPrefs,err:=api.Database.GetUserNotificationPreferences(ctx,user.ID)
234234
iferr!=nil {
235-
logger.Error(ctx,"failed to retrieve",slog.Error(err))
235+
logger.Error(ctx,"failed to retrieve preferences",slog.Error(err))
236236

237237
httpapi.Write(r.Context(),rw,http.StatusInternalServerError, codersdk.Response{
238238
Message:"Failed to retrieve user notifications preferences.",

‎coderd/notifications/metrics_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,9 @@ func TestCustomMethodMetricCollection(t *testing.T) {
390390
user:=createSampleUser(t,store)
391391

392392
_,err=enq.Enqueue(ctx,user.ID,template,map[string]string{"type":"success"},"test")
393+
require.NoError(t,err)
393394
_,err=enq.Enqueue(ctx,user.ID,anotherTemplate,map[string]string{"type":"success"},"test")
395+
require.NoError(t,err)
394396

395397
mgr.Run(ctx)
396398

‎coderd/notifications/notifications_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -723,17 +723,17 @@ func TestDisabledBeforeEnqueue(t *testing.T) {
723723
user:=createSampleUser(t,db)
724724

725725
// WHEN: the user has a preference set to not receive the "workspace deleted" notification
726-
templateId:=notifications.TemplateWorkspaceDeleted
726+
templateID:=notifications.TemplateWorkspaceDeleted
727727
n,err:=db.UpdateUserNotificationPreferences(ctx, database.UpdateUserNotificationPreferencesParams{
728728
UserID:user.ID,
729-
NotificationTemplateIds: []uuid.UUID{templateId},
729+
NotificationTemplateIds: []uuid.UUID{templateID},
730730
Disableds: []bool{true},
731731
})
732732
require.NoError(t,err,"failed to set preferences")
733733
require.EqualValues(t,1,n,"unexpected number of affected rows")
734734

735735
// THEN: enqueuing the "workspace deleted" notification should fail with an error
736-
_,err=enq.Enqueue(ctx,user.ID,templateId,map[string]string{},"test")
736+
_,err=enq.Enqueue(ctx,user.ID,templateID,map[string]string{},"test")
737737
require.ErrorIs(t,err,notifications.ErrCannotEnqueueDisabledNotification,"enqueueing did not fail with expected error")
738738
}
739739

@@ -763,14 +763,14 @@ func TestDisabledAfterEnqueue(t *testing.T) {
763763
user:=createSampleUser(t,db)
764764

765765
// GIVEN: a notification is enqueued which has not (yet) been disabled
766-
templateId:=notifications.TemplateWorkspaceDeleted
767-
msgId,err:=enq.Enqueue(ctx,user.ID,templateId,map[string]string{},"test")
766+
templateID:=notifications.TemplateWorkspaceDeleted
767+
msgID,err:=enq.Enqueue(ctx,user.ID,templateID,map[string]string{},"test")
768768
require.NoError(t,err)
769769

770770
// Disable the notification template.
771771
n,err:=db.UpdateUserNotificationPreferences(ctx, database.UpdateUserNotificationPreferencesParams{
772772
UserID:user.ID,
773-
NotificationTemplateIds: []uuid.UUID{templateId},
773+
NotificationTemplateIds: []uuid.UUID{templateID},
774774
Disableds: []bool{true},
775775
})
776776
require.NoError(t,err,"failed to set preferences")
@@ -787,7 +787,7 @@ func TestDisabledAfterEnqueue(t *testing.T) {
787787
})
788788
assert.NoError(ct,err)
789789
ifassert.Equal(ct,len(m),1) {
790-
assert.Equal(ct,m[0].ID.String(),msgId.String())
790+
assert.Equal(ct,m[0].ID.String(),msgID.String())
791791
assert.Contains(ct,m[0].StatusReason.String,"disabled by user")
792792
}
793793
},testutil.WaitLong,testutil.IntervalFast,"did not find the expected inhibited message")
@@ -836,12 +836,12 @@ func TestCustomNotificationMethod(t *testing.T) {
836836

837837
// GIVEN: a notification template which has a method explicitly set
838838
var (
839-
template=notifications.TemplateWorkspaceDormant
839+
template=notifications.TemplateWorkspaceDormant
840840
defaultMethod=database.NotificationMethodSmtp
841-
customMethod=database.NotificationMethodWebhook
841+
customMethod=database.NotificationMethodWebhook
842842
)
843843
out,err:=db.UpdateNotificationTemplateMethodByID(ctx, database.UpdateNotificationTemplateMethodByIDParams{
844-
ID:template,
844+
ID:template,
845845
Method: database.NullNotificationMethod{NotificationMethod:customMethod,Valid:true},
846846
})
847847
require.NoError(t,err)
@@ -850,8 +850,8 @@ func TestCustomNotificationMethod(t *testing.T) {
850850
// GIVEN: a manager configured with multiple dispatch methods
851851
cfg:=defaultNotificationsConfig(defaultMethod)
852852
cfg.SMTP= codersdk.NotificationsEmailConfig{
853-
From:"danny@coder.com",
854-
Hello:"localhost",
853+
From:"danny@coder.com",
854+
Hello:"localhost",
855855
Smarthost: serpent.HostPort{Host:"localhost",Port:fmt.Sprintf("%d",mockSMTPSrv.PortNumber())},
856856
}
857857
cfg.Webhook= codersdk.NotificationsWebhookConfig{
@@ -870,6 +870,7 @@ func TestCustomNotificationMethod(t *testing.T) {
870870
// WHEN: a notification of that template is enqueued, it should be delivered with the configured method - not the default.
871871
user:=createSampleUser(t,db)
872872
msgID,err:=enq.Enqueue(ctx,user.ID,template,map[string]string{},"test")
873+
require.NoError(t,err)
873874

874875
// THEN: the notification should be received by the custom dispatch method
875876
mgr.Run(ctx)

‎coderd/notifications/notifier.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ type notifier struct {
3434
quitchanany
3535
donechanany
3636

37-
handlersmap[database.NotificationMethod]Handler
37+
handlersmap[database.NotificationMethod]Handler
3838
metrics*Metrics
3939
}
4040

4141
funcnewNotifier(cfg codersdk.NotificationsConfig,id uuid.UUID,log slog.Logger,dbStore,hrmap[database.NotificationMethod]Handler,metrics*Metrics)*notifier {
4242
return&notifier{
43-
id:id,
44-
cfg:cfg,
45-
log:log.Named("notifier").With(slog.F("notifier_id",id)),
46-
quit:make(chanany),
47-
done:make(chanany),
48-
tick:time.NewTicker(cfg.FetchInterval.Value()),
49-
store:db,
50-
handlers:hr,
51-
metrics:metrics,
43+
id:id,
44+
cfg:cfg,
45+
log:log.Named("notifier").With(slog.F("notifier_id",id)),
46+
quit:make(chanany),
47+
done:make(chanany),
48+
tick:time.NewTicker(cfg.FetchInterval.Value()),
49+
store:db,
50+
handlers:hr,
51+
metrics:metrics,
5252
}
5353
}
5454

@@ -143,7 +143,6 @@ func (n *notifier) process(ctx context.Context, success chan<- dispatchResult, f
143143

144144
vareg errgroup.Group
145145
for_,msg:=rangemsgs {
146-
147146
// If a notification template has been disabled by the user after a notification was enqueued, mark it as inhibited
148147
ifmsg.Disabled {
149148
failure<-n.newInhibitedDispatch(msg)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp