Skip to content

Commit 880f518

Browse files
committed
Update newsletter email settings
1 parent b0f6784 commit 880f518

File tree

6 files changed

+16
-194
lines changed

6 files changed

+16
-194
lines changed

api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ $path
88
!.env.project
99
!.env.vault
1010
!.env.docker
11+
cmd/experiments/*

api/cmd/experiments/main.go

Lines changed: 0 additions & 194 deletions
This file was deleted.

api/pkg/entities/user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type User struct {
8585
NotificationMessageStatusEnabled bool `json:"notification_message_status_enabled" gorm:"default:true" example:"true"`
8686
NotificationWebhookEnabled bool `json:"notification_webhook_enabled" gorm:"default:true" example:"true"`
8787
NotificationHeartbeatEnabled bool `json:"notification_heartbeat_enabled" gorm:"default:true" example:"true"`
88+
NotificationNewsletterEnabled bool `json:"notification_newsletter_enabled" gorm:"default:true" example:"true"`
8889
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
8990
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`
9091
}

api/pkg/requests/user_notification_update_request.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type UserNotificationUpdate struct {
1010
MessageStatusEnabled bool `json:"message_status_enabled" example:"true"`
1111
WebhookEnabled bool `json:"webhook_enabled" example:"true"`
1212
HeartbeatEnabled bool `json:"heartbeat_enabled" example:"true"`
13+
NewsletterEnabled bool `json:"newsletter_enabled" example:"true"`
1314
}
1415

1516
// ToUserNotificationUpdateParams converts UserNotificationUpdate to services.UserNotificationUpdateParams
@@ -18,5 +19,6 @@ func (input *UserNotificationUpdate) ToUserNotificationUpdateParams() *services.
1819
MessageStatusEnabled: input.MessageStatusEnabled,
1920
WebhookEnabled: input.WebhookEnabled,
2021
HeartbeatEnabled: input.HeartbeatEnabled,
22+
NewsletterEnabled: input.NewsletterEnabled,
2123
}
2224
}

api/pkg/services/user_service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type UserNotificationUpdateParams struct {
131131
MessageStatusEnabled bool
132132
WebhookEnabled bool
133133
HeartbeatEnabled bool
134+
NewsletterEnabled bool
134135
}
135136

136137
// UpdateNotificationSettings for an entities.User
@@ -147,6 +148,7 @@ func (service *UserService) UpdateNotificationSettings(ctx context.Context, user
147148
user.NotificationWebhookEnabled = params.WebhookEnabled
148149
user.NotificationHeartbeatEnabled = params.HeartbeatEnabled
149150
user.NotificationMessageStatusEnabled = params.MessageStatusEnabled
151+
user.NotificationNewsletterEnabled = params.NewsletterEnabled
150152

151153
if err = service.repository.Update(ctx, user); err != nil {
152154
msg := fmt.Sprintf("cannot save user with id [%s] in [%T]", user.ID, service.repository)

web/pages/settings/index.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,13 @@
399399
hint="This switch controls email notifications we send when we your message is failed or expired."
400400
persistent-hint
401401
></v-switch>
402+
<v-switch
403+
v-model="notificationSettings.newsletter_enabled"
404+
label="Newsletter emails"
405+
:disabled="updatingEmailNotifications"
406+
hint="This switch controls newsletter emails about new features, updates, and promotions."
407+
persistent-hint
408+
></v-switch>
402409
<v-btn
403410
color="primary"
404411
:loading="updatingEmailNotifications"
@@ -870,6 +877,7 @@ export default Vue.extend({
870877
notificationSettings: {
871878
webhook_enabled: true,
872879
message_status_enabled: true,
880+
newsletter_enabled: true,
873881
heartbeat_enabled: true,
874882
},
875883
updatingWebhook: false,
@@ -965,6 +973,8 @@ export default Vue.extend({
965973
this.$store.getters.getUser.notification_message_status_enabled,
966974
heartbeat_enabled:
967975
this.$store.getters.getUser.notification_heartbeat_enabled,
976+
newsletter_enabled:
977+
this.$store.getters.getUser.notification_newsletter_enabled,
968978
}
969979
},
970980
showEditPhone(phoneId) {

0 commit comments

Comments
 (0)