Skip to content

Commit 7467eec

Browse files
committed
fix billing
1 parent 0f7d743 commit 7467eec

File tree

6 files changed

+42
-27
lines changed

6 files changed

+42
-27
lines changed

android/app/src/main/java/com/httpsms/MainActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class MainActivity : AppCompatActivity() {
7070
super.onResume()
7171
Timber.d( "on activity resume")
7272
redirectToLogin()
73+
setOwner(getPhoneNumber(this))
7374
refreshToken(this)
7475
setLastHeartbeatTimestamp(this)
7576
}

android/app/src/main/java/com/httpsms/Settings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import timber.log.Timber
66
import java.net.URI
77

88
object Settings {
9-
private const val DEFAULT_PHONE_NUMBER = "66836863" // NOT_FOUND :)
9+
private const val DEFAULT_PHONE_NUMBER = "NOT_FOUND"
1010

1111
private const val SETTINGS_OWNER = "SETTINGS_OWNER"
1212
private const val SETTINGS_ACTIVE = "SETTINGS_ACTIVE_STATUS"

api/pkg/di/container.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package di
22

33
import (
44
"context"
5+
"crypto/tls"
56
"fmt"
67
"net/http"
78
"os"
@@ -258,6 +259,10 @@ func (container *Container) Cache() cache.Cache {
258259
if err != nil {
259260
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot parse redis url [%s]", os.Getenv("REDIS_URL"))))
260261
}
262+
opt.TLSConfig = &tls.Config{
263+
MinVersion: tls.VersionTLS12,
264+
}
265+
261266
return cache.NewRedisCache(container.Tracer(), redis.NewClient(opt))
262267
}
263268

api/pkg/emails/hermes_user_email_factory.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ func (factory *hermesUserEmailFactory) UsageLimitExceeded(user *entities.User) (
1919
email := hermes.Email{
2020
Body: hermes.Body{
2121
Intros: []string{
22-
fmt.Sprintf("You have exceeded your limit of [%d] messages on your [%s] plan.", user.SubscriptionName.Limit(), user.SubscriptionName),
23-
fmt.Sprintf("Upgrade your plan to send more messages on https://httpsms.com/billing"),
22+
fmt.Sprintf("You have exceeded your limit of %d messages on your %s plan.", user.SubscriptionName.Limit(), user.SubscriptionName),
2423
},
2524
Actions: []hermes.Action{
2625
{
27-
Instructions: "Click the button below to upgrade your plan",
26+
Instructions: "Click the button below to upgrade your plan and continue sending more messages",
2827
Button: hermes.Button{
2928
Color: "#329ef4",
3029
TextColor: "#FFFFFF",
31-
Text: "UPGRADE PLAN",
30+
Text: "Upgrade your httpSMS plan",
3231
Link: "https://httpsms.com/billing",
3332
},
3433
},
@@ -65,12 +64,12 @@ func (factory *hermesUserEmailFactory) UsageLimitAlert(user *entities.User, usag
6564
email := hermes.Email{
6665
Body: hermes.Body{
6766
Intros: []string{
68-
fmt.Sprintf("This is a friendly notification that you have exceeded %d of your monthly SMS limit on the %s plan.", percent, user.SubscriptionName),
69-
fmt.Sprintf("You have sent %d messages and received %d messages. Upgrade your plan to send more messages on https://httpsms.com/billing", usage.SentMessages, usage.ReceivedMessages),
67+
fmt.Sprintf("This is a friendly notification that you have exceeded %d%% of your monthly SMS limit on the %s plan.", percent, user.SubscriptionName),
68+
fmt.Sprintf("You have sent %d messages and received %d messages using httpSMS this month.", usage.SentMessages, usage.ReceivedMessages),
7069
},
7170
Actions: []hermes.Action{
7271
{
73-
Instructions: "Click the button below to upgrade your plan",
72+
Instructions: "Click the button below to upgrade your plan so you can continue without any disruptions",
7473
Button: hermes.Button{
7574
Color: "#329ef4",
7675
TextColor: "#FFFFFF",

web/layouts/default.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ export default class DefaultLayout extends Vue {
3737
}
3838
3939
mounted() {
40-
// if (this.$route.name !== 'index') {
41-
// this.$store.dispatch('setNextRoute', this.$route.path)
42-
// this.$router.push({ name: 'index' })
43-
// }
40+
this.startPoller()
4441
}
4542
4643
beforeDestroy(): void {
@@ -57,7 +54,7 @@ export default class DefaultLayout extends Vue {
5754
if (this.$store.getters.getAuthUser && this.$store.getters.getOwner) {
5855
promises.push(
5956
this.$store.dispatch('loadThreads'),
60-
this.$store.dispatch('getHeartbeat')
57+
this.$store.dispatch('getHeartbeat'),
6158
)
6259
}
6360
@@ -69,8 +66,8 @@ export default class DefaultLayout extends Vue {
6966
promises.push(
7067
this.$store.dispatch(
7168
'loadThreadMessages',
72-
this.$store.getters.getThread.id
73-
)
69+
this.$store.getters.getThread.id,
70+
),
7471
)
7572
}
7673
await Promise.all(promises)

web/store/index.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export const actions = {
360360
fcm_token: phone.fcm_token,
361361
phone_number: phone.phone_number,
362362
message_expiration_seconds: parseInt(
363-
phone.message_expiration_seconds.toString()
363+
phone.message_expiration_seconds.toString(),
364364
),
365365
max_send_attempts: parseInt(phone.max_send_attempts.toString()),
366366
messages_per_minute: parseInt(phone.messages_per_minute.toString()),
@@ -380,7 +380,7 @@ export const actions = {
380380

381381
async handleAxiosError(
382382
context: ActionContext<State, State>,
383-
error: AxiosError
383+
error: AxiosError,
384384
) {
385385
const errorMessage =
386386
error.response?.data?.data[Object.keys(error.response?.data?.data)[0]][0]
@@ -415,9 +415,22 @@ export const actions = {
415415

416416
async sendMessage(
417417
context: ActionContext<State, State>,
418-
request: SendMessageRequest
418+
request: SendMessageRequest,
419419
) {
420-
await axios.post('/v1/messages/send', request)
420+
try {
421+
const response = await axios.post('/v1/messages/send', request)
422+
await context.dispatch('addNotification', {
423+
message: response.data.message,
424+
type: 'success',
425+
})
426+
} catch (e) {
427+
await context.dispatch('addNotification', {
428+
message:
429+
(e as AxiosError).response?.data?.message ??
430+
'Error while sending message',
431+
type: 'error',
432+
})
433+
}
421434
await Promise.all([
422435
context.dispatch('loadThreadMessages', context.getters.getThread.id),
423436
context.dispatch('loadThreads'),
@@ -430,7 +443,7 @@ export const actions = {
430443

431444
addNotification(
432445
context: ActionContext<State, State>,
433-
request: NotificationRequest
446+
request: NotificationRequest,
434447
) {
435448
context.commit('setNotification', request)
436449
},
@@ -445,7 +458,7 @@ export const actions = {
445458

446459
async loadThreadMessages(
447460
context: ActionContext<State, State>,
448-
threadId: string | null
461+
threadId: string | null,
449462
) {
450463
await context.commit('setThreadId', threadId)
451464
const response = await axios.get('/v1/messages', {
@@ -460,7 +473,7 @@ export const actions = {
460473

461474
async setAuthUser(
462475
context: ActionContext<State, State>,
463-
user: AuthUser | null | undefined
476+
user: AuthUser | null | undefined,
464477
) {
465478
const userChanged = user?.id !== context.getters.getAuthUser?.id
466479

@@ -477,7 +490,7 @@ export const actions = {
477490
])
478491

479492
const phone = context.getters.getPhones.find(
480-
(x: Phone) => x.id === context.getters.getUser.active_phone_id
493+
(x: Phone) => x.id === context.getters.getUser.active_phone_id,
481494
)
482495
if (phone) {
483496
await context.dispatch('setOwner', phone.phone_number)
@@ -487,7 +500,7 @@ export const actions = {
487500
async onAuthStateChanged(
488501
context: ActionContext<State, State>,
489502
// @ts-ignore
490-
{ authUser }
503+
{ authUser },
491504
) {
492505
if (authUser == null) {
493506
context.commit('setAuthUser', null)
@@ -520,7 +533,7 @@ export const actions = {
520533

521534
async updateThread(
522535
context: ActionContext<State, State>,
523-
payload: { threadId: string; isArchived: boolean }
536+
payload: { threadId: string; isArchived: boolean },
524537
) {
525538
await axios.put(`/v1/message-threads/${payload.threadId}`, {
526539
is_archived: payload.isArchived,
@@ -573,7 +586,7 @@ export const actions = {
573586

574587
createWebhook(
575588
context: ActionContext<State, State>,
576-
payload: RequestsWebhookStore
589+
payload: RequestsWebhookStore,
577590
) {
578591
return new Promise<EntitiesWebhook>((resolve, reject) => {
579592
axios
@@ -621,7 +634,7 @@ export const actions = {
621634

622635
updateWebhook(
623636
context: ActionContext<State, State>,
624-
payload: RequestsWebhookUpdate & { id: string }
637+
payload: RequestsWebhookUpdate & { id: string },
625638
) {
626639
return new Promise<EntitiesWebhook>((resolve, reject) => {
627640
axios

0 commit comments

Comments
 (0)