1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-25 00:07:36 +02:00

Basic user access endpoint

This commit is contained in:
binwiederhier 2022-12-30 14:20:48 -05:00
parent b131d676c4
commit bd86e3d951
9 changed files with 95 additions and 23 deletions
server

View file

@ -45,6 +45,7 @@ import (
reset daily limits for users
Account usage not updated "in real time"
max token issue limit
user db startup queries -> foreign keys
Sync:
- "mute" setting
- figure out what settings are "web" or "phone"
@ -101,6 +102,7 @@ var (
accountPasswordPath = "/v1/account/password"
accountSettingsPath = "/v1/account/settings"
accountSubscriptionPath = "/v1/account/subscription"
accountAccessPath = "/v1/account/access"
accountSubscriptionSingleRegex = regexp.MustCompile(`^/v1/account/subscription/([-_A-Za-z0-9]{16})$`)
matrixPushPath = "/_matrix/push/v1/notify"
staticRegex = regexp.MustCompile(`^/static/.+`)
@ -357,6 +359,8 @@ func (s *Server) handleInternal(w http.ResponseWriter, r *http.Request, v *visit
return s.ensureUser(s.handleAccountSubscriptionChange)(w, r, v)
} else if r.Method == http.MethodDelete && accountSubscriptionSingleRegex.MatchString(r.URL.Path) {
return s.ensureUser(s.handleAccountSubscriptionDelete)(w, r, v)
} else if r.Method == http.MethodPost && r.URL.Path == accountAccessPath {
return s.ensureUser(s.handleAccountAccessAdd)(w, r, v)
} else if r.Method == http.MethodGet && r.URL.Path == matrixPushPath {
return s.handleMatrixDiscovery(w)
} else if r.Method == http.MethodGet && staticRegex.MatchString(r.URL.Path) {