mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-02 19:35:53 +02:00
Phone number verification in publishing
This commit is contained in:
parent
69b01bc468
commit
4b9e0c5c38
4 changed files with 35 additions and 14 deletions
server
|
@ -707,17 +707,14 @@ func (s *Server) handlePublishInternal(r *http.Request, v *visitor) (*message, e
|
|||
} else if email != "" && !vrate.EmailAllowed() {
|
||||
return nil, errHTTPTooManyRequestsLimitEmails.With(t)
|
||||
} else if call != "" {
|
||||
call, err = s.convertPhoneNumber(v.User(), call)
|
||||
if err != nil {
|
||||
return nil, errHTTPBadRequestInvalidPhoneNumber.With(t)
|
||||
}
|
||||
if !vrate.CallAllowed() {
|
||||
var httpErr *errHTTP
|
||||
call, httpErr = s.convertPhoneNumber(v.User(), call)
|
||||
if httpErr != nil {
|
||||
return nil, httpErr.With(t)
|
||||
} else if !vrate.CallAllowed() {
|
||||
return nil, errHTTPTooManyRequestsLimitCalls.With(t)
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME check allowed phone numbers
|
||||
|
||||
if m.PollID != "" {
|
||||
m = newPollRequestMessage(t.ID, m.PollID)
|
||||
}
|
||||
|
@ -741,6 +738,7 @@ func (s *Server) handlePublishInternal(r *http.Request, v *visitor) (*message, e
|
|||
"message_firebase": firebase,
|
||||
"message_unifiedpush": unifiedpush,
|
||||
"message_email": email,
|
||||
"message_call": call,
|
||||
})
|
||||
if ev.IsTrace() {
|
||||
ev.Field("message_body", util.MaybeMarshalJSON(m)).Trace("Received message")
|
||||
|
@ -913,7 +911,7 @@ func (s *Server) parsePublishParams(r *http.Request, m *message) (cache bool, fi
|
|||
}
|
||||
call = readParam(r, "x-call", "call")
|
||||
if call != "" && s.config.TwilioAccount == "" {
|
||||
return false, false, "", "", false, errHTTPBadRequestTwilioDisabled
|
||||
return false, false, "", "", false, errHTTPBadRequestPhoneCallsDisabled
|
||||
} else if call != "" && !isBoolValue(call) && !phoneNumberRegex.MatchString(call) {
|
||||
return false, false, "", "", false, errHTTPBadRequestPhoneNumberInvalid
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue