@@ -918,6 +918,7 @@ func (api *API) putUserStatus(status database.UserStatus) func(rw http.ResponseW
918
918
919
919
func (api * API ) notifyUserStatusChanged (ctx context.Context , actingUserName string , targetUser database.User , status database.UserStatus ) error {
920
920
var labels map [string ]string
921
+ var data map [string ]any
921
922
var adminTemplateID , personalTemplateID uuid.UUID
922
923
switch status {
923
924
case database .UserStatusSuspended :
@@ -926,6 +927,9 @@ func (api *API) notifyUserStatusChanged(ctx context.Context, actingUserName stri
926
927
"suspended_account_user_name" : targetUser .Name ,
927
928
"initiator" : actingUserName ,
928
929
}
930
+ data = map [string ]any {
931
+ "user" : map [string ]any {"id" : targetUser .ID , "name" : targetUser .Name , "email" : targetUser .Email },
932
+ }
929
933
adminTemplateID = notifications .TemplateUserAccountSuspended
930
934
personalTemplateID = notifications .TemplateYourAccountSuspended
931
935
case database .UserStatusActive :
@@ -934,6 +938,9 @@ func (api *API) notifyUserStatusChanged(ctx context.Context, actingUserName stri
934
938
"activated_account_user_name" : targetUser .Name ,
935
939
"initiator" : actingUserName ,
936
940
}
941
+ data = map [string ]any {
942
+ "user" : map [string ]any {"id" : targetUser .ID , "name" : targetUser .Name , "email" : targetUser .Email },
943
+ }
937
944
adminTemplateID = notifications .TemplateUserAccountActivated
938
945
personalTemplateID = notifications .TemplateYourAccountActivated
939
946
default :
@@ -949,16 +956,16 @@ func (api *API) notifyUserStatusChanged(ctx context.Context, actingUserName stri
949
956
// Send notifications to user admins and affected user
950
957
for _ , u := range userAdmins {
951
958
// nolint:gocritic // Need notifier actor to enqueue notifications
952
- if _ , err := api .NotificationsEnqueuer .Enqueue (dbauthz .AsNotifier (ctx ), u .ID , adminTemplateID ,
953
- labels , "api-put-user-status" ,
959
+ if _ , err := api .NotificationsEnqueuer .EnqueueWithData (dbauthz .AsNotifier (ctx ), u .ID , adminTemplateID ,
960
+ labels , data , "api-put-user-status" ,
954
961
targetUser .ID ,
955
962
); err != nil {
956
963
api .Logger .Warn (ctx , "unable to notify about changed user's status" , slog .F ("affected_user" , targetUser .Username ), slog .Error (err ))
957
964
}
958
965
}
959
966
// nolint:gocritic // Need notifier actor to enqueue notifications
960
- if _ , err := api .NotificationsEnqueuer .Enqueue (dbauthz .AsNotifier (ctx ), targetUser .ID , personalTemplateID ,
961
- labels , "api-put-user-status" ,
967
+ if _ , err := api .NotificationsEnqueuer .EnqueueWithData (dbauthz .AsNotifier (ctx ), targetUser .ID , personalTemplateID ,
968
+ labels , data , "api-put-user-status" ,
962
969
targetUser .ID ,
963
970
); err != nil {
964
971
api .Logger .Warn (ctx , "unable to notify user about status change of their account" , slog .F ("affected_user" , targetUser .Username ), slog .Error (err ))
@@ -1424,13 +1431,20 @@ func (api *API) CreateUser(ctx context.Context, store database.Store, req Create
1424
1431
}
1425
1432
1426
1433
for _ , u := range userAdmins {
1427
- // nolint:gocritic // Need notifier actor to enqueue notifications
1428
- if _ , err := api .NotificationsEnqueuer .Enqueue (dbauthz .AsNotifier (ctx ), u .ID , notifications .TemplateUserAccountCreated ,
1434
+ if _ , err := api .NotificationsEnqueuer .EnqueueWithData (
1435
+ // nolint:gocritic // Need notifier actor to enqueue notifications
1436
+ dbauthz .AsNotifier (ctx ),
1437
+ u .ID ,
1438
+ notifications .TemplateUserAccountCreated ,
1429
1439
map [string ]string {
1430
1440
"created_account_name" : user .Username ,
1431
1441
"created_account_user_name" : user .Name ,
1432
1442
"initiator" : req .accountCreatorName ,
1433
- }, "api-users-create" ,
1443
+ },
1444
+ map [string ]any {
1445
+ "user" : map [string ]any {"id" : user .ID , "name" : user .Name , "email" : user .Email },
1446
+ },
1447
+ "api-users-create" ,
1434
1448
user .ID ,
1435
1449
); err != nil {
1436
1450
api .Logger .Warn (ctx , "unable to notify about created user" , slog .F ("created_user" , user .Username ), slog .Error (err ))
0 commit comments