自动补充 MLS 一次性密钥包

This commit is contained in:
xhgit committed 2026-11-13 23:44:52 +08:00
1 parent 6b728a0996
commit cf8129f4aa
8 files changed
+69 -11

No files matched your search

+1
View File
@@ -53,6 +53,7 @@ func New(accounts *account.Store, contactStore *contacts.Store, envelopeStore *d
mux.HandleFunc("GET /api/v1/contacts/{id}/devices", a.authorized(a.contactDevices))
mux.HandleFunc("POST /api/v1/contacts/{id}/devices/{device}/claim", a.authorized(a.claimPackage))
mux.HandleFunc("POST /api/v1/key-packages", a.authorized(a.publishPackage))
mux.HandleFunc("GET /api/v1/key-packages", a.authorized(a.packageStatus))
mux.HandleFunc("POST /api/v1/mls-credential", a.authorized(a.publishCredential))
mux.HandleFunc("POST /api/v1/attachments/{id}", a.authorized(a.uploadAttachment))
mux.HandleFunc("GET /api/v1/attachments/{id}", a.authorized(a.downloadAttachment))
+12
View File
@@ -51,6 +51,18 @@ func (a *API) publishPackage(w http.ResponseWriter, r *http.Request, _ string, i
}
}
func (a *API) packageStatus(w http.ResponseWriter, r *http.Request, _ string, identity account.Identity) {
if !a.limit(w, r, "package-status:"+identity.Device.ID, 60) {
return
}
available, err := a.delivery.AvailablePackages(r.Context(), identity.Device.ID)
if err != nil {
unavailable(w, err)
return
}
respond(w, 200, map[string]int{"available": available})
}
func (a *API) claimPackage(w http.ResponseWriter, r *http.Request, _ string, identity account.Identity) {
id, device := strings.ToLower(r.PathValue("id")), strings.ToLower(r.PathValue("device"))
if !uuidPattern.MatchString(id) || !uuidPattern.MatchString(device) {