Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Add button to disable notifications

Acho Arnold939ce20861a9
diff --git a/api/pkg/emails/hermes_notification_email_factory.go b/api/pkg/emails/hermes_notification_email_factory.go
index e42cf814..c3e8b1b9 100644
--- a/api/pkg/emails/hermes_notification_email_factory.go
+++ b/api/pkg/emails/hermes_notification_email_factory.go
@@ -47,14 +47,14 @@ func (factory *hermesNotificationEmailFactory) DiscordSendFailed(user *entities.
Button: hermes.Button{
Color: "#329ef4",
TextColor: "#FFFFFF",
- Text: "Settings",
- Link: "https://httpsms.com/settings",
+ Text: "DISCORD SETTINGS",
+ Link: "https://httpsms.com/settings/#discord-settings",
},
},
},
Signature: "Cheers",
Outros: []string{
- fmt.Sprintf("Don't hesitate to contact us by replying to this email."),
+ fmt.Sprintf("Don't hesitate to contact us by replying to this email. You can disable this email notification on https://httpsms.com/settings/#email-notifications"),
},
},
}
@@ -98,14 +98,14 @@ func (factory *hermesNotificationEmailFactory) WebhookSendFailed(user *entities.
Button: hermes.Button{
Color: "#329ef4",
TextColor: "#FFFFFF",
- Text: "Settings",
- Link: "https://httpsms.com/settings",
+ Text: "WEBHOOK SETTINGS",
+ Link: "https://httpsms.com/settings/#webhook-settings",
},
},
},
Signature: "Cheers",
Outros: []string{
- fmt.Sprintf("Don't hesitate to contact us by replying to this email."),
+ fmt.Sprintf("Don't hesitate to contact us by replying to this email. You can disable this email notification on https://httpsms.com/settings/#email-notifications"),
},
},
}
@@ -147,14 +147,14 @@ func (factory *hermesNotificationEmailFactory) MessageExpired(user *entities.Use
Button: hermes.Button{
Color: "#329ef4",
TextColor: "#FFFFFF",
- Text: "View Messages",
+ Text: "VIEW MESSAGES",
Link: "https://httpsms.com/threads",
},
},
},
Signature: "Cheers",
Outros: []string{
- fmt.Sprintf("Don't hesitate to contact us by replying to this email."),
+ fmt.Sprintf("Don't hesitate to contact us by replying to this email. You can disable this email notification on https://httpsms.com/settings/#email-notifications"),
},
},
}
@@ -197,14 +197,14 @@ func (factory *hermesNotificationEmailFactory) MessageFailed(user *entities.User
Button: hermes.Button{
Color: "#329ef4",
TextColor: "#FFFFFF",
- Text: "View Messages",
+ Text: "VIEW MESSAGES",
Link: "https://httpsms.com/threads",
},
},
},
Signature: "Cheers",
Outros: []string{
- fmt.Sprintf("Don't hesitate to contact us by replying to this email."),
+ fmt.Sprintf("Don't hesitate to contact us by replying to this email. You can disable this email notification on https://httpsms.com/settings/#email-notifications"),
},
},
}
diff --git a/api/pkg/emails/hermes_user_email_factory.go b/api/pkg/emails/hermes_user_email_factory.go
index 12ce1402..8a177f0b 100644
--- a/api/pkg/emails/hermes_user_email_factory.go
+++ b/api/pkg/emails/hermes_user_email_factory.go
@@ -28,7 +28,7 @@ func (factory *hermesUserEmailFactory) UsageLimitExceeded(user *entities.User) (
Button: hermes.Button{
Color: "#329ef4",
TextColor: "#FFFFFF",
- Text: "Upgrade your httpSMS plan",
+ Text: "UPGRADE YOUR PLAN",
Link: "https://httpsms.com/billing",
},
},
@@ -74,7 +74,7 @@ func (factory *hermesUserEmailFactory) UsageLimitAlert(user *entities.User, usag
Button: hermes.Button{
Color: "#329ef4",
TextColor: "#FFFFFF",
- Text: "UPGRADE PLAN",
+ Text: "UPGRADE YOUR PLAN",
Link: "https://httpsms.com/billing",
},
},
@@ -140,7 +140,7 @@ func (factory *hermesUserEmailFactory) PhoneDead(user *entities.User, lastHeartb
Title: "Hey,",
Signature: "Cheers",
Outros: []string{
- fmt.Sprintf("Don't hesitate to contact us by replying to this email."),
+ fmt.Sprintf("Don't hesitate to contact us by replying to this email. You can disable this email notification on https://httpsms.com/settings/#email-notifications"),
},
},
}
diff --git a/api/pkg/services/email_notification_service.go b/api/pkg/services/email_notification_service.go
index 0a7bcaff..1fa9bc78 100644
--- a/api/pkg/services/email_notification_service.go
+++ b/api/pkg/services/email_notification_service.go
@@ -70,6 +70,11 @@ func (service *EmailNotificationService) NotifyMessageExpired(ctx context.Contex
return service.tracer.WrapErrorSpan(span, stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), msg))
}
+ if !user.NotificationMessageStatusEnabled {
+ ctxLogger.Info(fmt.Sprintf("[%s] email notifications disabled for user [%s] with owner [%s]", events.EventTypeMessageSendExpired, payload.UserID, payload.Owner))
+ return nil
+ }
+
email, err := service.factory.MessageExpired(user, payload.MessageID, payload.Owner, payload.Contact, payload.Content)
if err != nil {
msg := fmt.Sprintf("cannot create email for user with ID [%s] and for expired message with ID [%s]", payload.UserID, payload.MessageID)
@@ -103,6 +108,11 @@ func (service *EmailNotificationService) NotifyMessageFailed(ctx context.Context
return service.tracer.WrapErrorSpan(span, stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), msg))
}
+ if !user.NotificationMessageStatusEnabled {
+ ctxLogger.Info(fmt.Sprintf("[%s] email notifications disabled for user [%s] with owner [%s]", events.EventTypeMessageSendFailed, payload.UserID, payload.Owner))
+ return nil
+ }
+
email, err := service.factory.MessageFailed(user, payload.ID, payload.Owner, payload.Contact, payload.Content, payload.ErrorMessage)
if err != nil {
msg := fmt.Sprintf("cannot create email for user with ID [%s] for [%s] message with ID [%s]", payload.UserID, payload.ID)
@@ -136,6 +146,11 @@ func (service *EmailNotificationService) NotifyWebhookSendFailed(ctx context.Con
return service.tracer.WrapErrorSpan(span, stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), msg))
}
+ if !user.NotificationWebhookEnabled {
+ ctxLogger.Info(fmt.Sprintf("[%s] email notifications disabled for user [%s] with owner [%s]", events.EventTypeWebhookSendFailed, payload.UserID, payload.Owner))
+ return nil
+ }
+
email, err := service.factory.WebhookSendFailed(user, payload)
if err != nil {
msg := fmt.Sprintf("cannot create [%s] email for user with ID [%s] for [%s] event with ID [%s]", events.EventTypeWebhookSendFailed, payload.UserID, payload.EventType, payload.EventID)
@@ -169,6 +184,11 @@ func (service *EmailNotificationService) NotifyDiscordSendFailed(ctx context.Con
return service.tracer.WrapErrorSpan(span, stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), msg))
}
+ if !user.NotificationWebhookEnabled {
+ ctxLogger.Info(fmt.Sprintf("[%s] email notifications disabled for user [%s] with owner [%s]", events.EventTypeDiscordSendFailed, payload.UserID, payload.Owner))
+ return nil
+ }
+
email, err := service.factory.DiscordSendFailed(user, payload)
if err != nil {
msg := fmt.Sprintf("cannot create email for user with ID [%s] for [%s] event and message with ID [%s]", payload.UserID, payload.EventType, payload.MessageID)
diff --git a/api/pkg/services/user_service.go b/api/pkg/services/user_service.go
index 9743af37..b0a18ab9 100644
--- a/api/pkg/services/user_service.go
+++ b/api/pkg/services/user_service.go
@@ -156,6 +156,11 @@ func (service *UserService) SendPhoneDeadEmail(ctx context.Context, params *User
return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
}
+ if !user.NotificationHeartbeatEnabled {
+ ctxLogger.Info(fmt.Sprintf("[%s] email notifications disabled for user [%s] with owner [%s]", events.EventTypePhoneHeartbeatDead, params.UserID, params.Owner))
+ return nil
+ }
+
email, err := service.emailFactory.PhoneDead(user, params.LastHeartbeatTimestamp, params.Owner)
if err != nil {
msg := fmt.Sprintf("cannot create phone dead email for user [%s]", params.UserID)
diff --git a/web/pages/settings/index.vue b/web/pages/settings/index.vue
index eeb1db46..060650d2 100644
--- a/web/pages/settings/index.vue
+++ b/web/pages/settings/index.vue
@@ -91,7 +91,7 @@
>Documentation</v-btn
>
</div>
- <h5 id="webhooks" class="text-h4 mb-3 mt-12">Webhooks</h5>
+ <h5 id="webhook-settings" class="text-h4 mb-3 mt-12">Webhooks</h5>
<p class="text--secondary">
Webhooks allow us to send events to your server for example when
the android phone receives an SMS message we can forward the
@@ -164,10 +164,12 @@
>Documentation</v-btn
>
</div>
- <h5 class="text-h4 mb-3 mt-12">Discord Integration</h5>
+ <h5 id="discord-settings" class="text-h4 mb-3 mt-12">
+ Discord Integration
+ </h5>
<p class="text--secondary">
Send and receive SMS messages without leaving your discord server
- with the httpsms discord app using the
+ with the httpSMS discord app using the
<code>/httpsms</code> command.
</p>
<div v-if="loadingDiscordIntegrations">
@@ -854,7 +856,7 @@ export default Vue.extend({
},
async updatePhone() {
- thisPhone = true
+ this.updatingPhone = true
await this.$store.dispatch('clearAxiosError')
this.$store.dispatch('updatePhone', this.activePhone).finally(() => {
if (!this.$store.getters.getAxiosError) {