mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-12-14 11:47:33 +00:00
The last one
This commit is contained in:
parent
92c384374a
commit
fc1087a42b
3 changed files with 9 additions and 1 deletions
|
@ -87,7 +87,7 @@ func (s *Server) ensureAdmin(next handleFunc) handleFunc {
|
|||
|
||||
func (s *Server) ensureCallsEnabled(next handleFunc) handleFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request, v *visitor) error {
|
||||
if s.config.TwilioAccount == "" {
|
||||
if s.config.TwilioAccount == "" || s.userManager == nil {
|
||||
return errHTTPNotFound
|
||||
}
|
||||
return next(w, r, v)
|
||||
|
|
|
@ -58,6 +58,8 @@ func (s *Server) convertPhoneNumber(u *user.User, phoneNumber string) (string, *
|
|||
return "", errHTTPBadRequestPhoneNumberNotVerified
|
||||
}
|
||||
|
||||
// callPhone calls the Twilio API to make a phone call to the given phone number, using the given message.
|
||||
// Failures will be logged, but not returned to the caller.
|
||||
func (s *Server) callPhone(v *visitor, r *http.Request, m *message, to string) {
|
||||
u, sender := v.User(), m.Sender.String()
|
||||
if u != nil {
|
||||
|
|
|
@ -910,6 +910,12 @@ func TestUser_PhoneNumberAddListRemove(t *testing.T) {
|
|||
phoneNumbers, err = a.PhoneNumbers(phil.ID)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, 0, len(phoneNumbers))
|
||||
|
||||
// Paranoia check: We do NOT want to keep phone numbers in there
|
||||
rows, err := a.db.Query(`SELECT * FROM user_phone`)
|
||||
require.Nil(t, err)
|
||||
require.False(t, rows.Next())
|
||||
require.Nil(t, rows.Close())
|
||||
}
|
||||
|
||||
func TestUser_PhoneNumberAdd_Multiple_Users_Same_Number(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue