check recipient before sending an sms
This commit is contained in:
parent
695bfed349
commit
fb2dc003b8
@ -1709,13 +1709,18 @@ func (h *MenuHandlers) InviteValidRecipient(ctx context.Context, sym string, inp
|
|||||||
l := gotext.NewLocale(translationDir, code)
|
l := gotext.NewLocale(translationDir, code)
|
||||||
l.AddDomain("default")
|
l.AddDomain("default")
|
||||||
|
|
||||||
recipient, _ := store.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
recipient, err := store.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
||||||
if len(recipient) == 0 {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "recipient is empty", "key", storedb.DATA_TEMPORARY_VALUE)
|
logg.ErrorCtxf(ctx, "Failed to read invalid recipient info", "error", err)
|
||||||
return res, fmt.Errorf("Data error encountered")
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := h.accountService.SendUpsellSMS(ctx, sessionId, string(recipient))
|
if !phone.IsValidPhoneNumber(string(recipient)) {
|
||||||
|
logg.InfoCtxf(ctx, "corrupted recipient", "key", storedb.DATA_TEMPORARY_VALUE, "recipient", recipient)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = h.accountService.SendUpsellSMS(ctx, sessionId, string(recipient))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Content = l.Get("Your invite request for %s to Sarafu Network failed. Please try again later.", string(recipient))
|
res.Content = l.Get("Your invite request for %s to Sarafu Network failed. Please try again later.", string(recipient))
|
||||||
return res, nil
|
return res, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user