Skip to content

Commit

Permalink
Update newsletter email settings
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed Nov 26, 2024
1 parent b0f6784 commit 880f518
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 194 deletions.
1 change: 1 addition & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ $path
!.env.project
!.env.vault
!.env.docker
cmd/experiments/*
194 changes: 0 additions & 194 deletions api/cmd/experiments/main.go

This file was deleted.

1 change: 1 addition & 0 deletions api/pkg/entities/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type User struct {
NotificationMessageStatusEnabled bool `json:"notification_message_status_enabled" gorm:"default:true" example:"true"`
NotificationWebhookEnabled bool `json:"notification_webhook_enabled" gorm:"default:true" example:"true"`
NotificationHeartbeatEnabled bool `json:"notification_heartbeat_enabled" gorm:"default:true" example:"true"`
NotificationNewsletterEnabled bool `json:"notification_newsletter_enabled" gorm:"default:true" example:"true"`
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`
}
Expand Down
2 changes: 2 additions & 0 deletions api/pkg/requests/user_notification_update_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type UserNotificationUpdate struct {
MessageStatusEnabled bool `json:"message_status_enabled" example:"true"`
WebhookEnabled bool `json:"webhook_enabled" example:"true"`
HeartbeatEnabled bool `json:"heartbeat_enabled" example:"true"`
NewsletterEnabled bool `json:"newsletter_enabled" example:"true"`
}

// ToUserNotificationUpdateParams converts UserNotificationUpdate to services.UserNotificationUpdateParams
Expand All @@ -18,5 +19,6 @@ func (input *UserNotificationUpdate) ToUserNotificationUpdateParams() *services.
MessageStatusEnabled: input.MessageStatusEnabled,
WebhookEnabled: input.WebhookEnabled,
HeartbeatEnabled: input.HeartbeatEnabled,
NewsletterEnabled: input.NewsletterEnabled,
}
}
2 changes: 2 additions & 0 deletions api/pkg/services/user_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type UserNotificationUpdateParams struct {
MessageStatusEnabled bool
WebhookEnabled bool
HeartbeatEnabled bool
NewsletterEnabled bool
}

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

if err = service.repository.Update(ctx, user); err != nil {
msg := fmt.Sprintf("cannot save user with id [%s] in [%T]", user.ID, service.repository)
Expand Down
10 changes: 10 additions & 0 deletions web/pages/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@
hint="This switch controls email notifications we send when we your message is failed or expired."
persistent-hint
></v-switch>
<v-switch
v-model="notificationSettings.newsletter_enabled"
label="Newsletter emails"
:disabled="updatingEmailNotifications"
hint="This switch controls newsletter emails about new features, updates, and promotions."
persistent-hint
></v-switch>
<v-btn
color="primary"
:loading="updatingEmailNotifications"
Expand Down Expand Up @@ -870,6 +877,7 @@ export default Vue.extend({
notificationSettings: {
webhook_enabled: true,
message_status_enabled: true,
newsletter_enabled: true,
heartbeat_enabled: true,
},
updatingWebhook: false,
Expand Down Expand Up @@ -965,6 +973,8 @@ export default Vue.extend({
this.$store.getters.getUser.notification_message_status_enabled,
heartbeat_enabled:
this.$store.getters.getUser.notification_heartbeat_enabled,
newsletter_enabled:
this.$store.getters.getUser.notification_newsletter_enabled,
}
},
showEditPhone(phoneId) {
Expand Down

0 comments on commit 880f518

Please sign in to comment.