tickets
All repositories: gitoria
2.0 KB
// Thin token-only wrappers; cookies, project keys and ident access keys do not own subscriptions.import { Response } from 'hl:http1'import { userOfBearer } from './users.hl'import { jsonErrorAt } from './jsoncheck.hl'import { hdr, fail, unauthorizedFor, wantsMarkdown } from './api-helpers.hl'import { subscriptionsFor, createSubscription, removeSubscription, subscriptionDelta } from './subscriptions.hl'static answer = (status, data, markdown) => {return new Response(markdown ? data : JSON.stringify(data), { status = status headers = hdr({ 'Content-Type' = markdown ? 'text/markdown; charset=utf-8' : 'application/json; charset=utf-8' 'Cache-Control' = 'no-store' 'Vary' = 'Accept' }) })}static result = (r, status) => { return answer(r.error != null ? (r.forbidden == true ? 403 : (r.status != null ? r.status : 400)) : status, r, false) }static subscriptionsApi = (route, req) => {if (req.method != 'GET' && req.method != 'POST') { return fail(405, 'GET or POST') }u = userOfBearer(req.headers['authorization'])if (u == null) { return unauthorizedFor('subscriptions') }if (req.method == 'GET') { return result(subscriptionsFor(u), 200) }if (req.body == null || req.body == '' || req.body.length > 32768 || jsonErrorAt(req.body) >= 0) { return fail(400, 'invalid JSON body (maximum 32768 characters)') }return result(createSubscription(u, JSON.parse(req.body)), 201)}static deltaApi = (route, req) => {if (req.method != 'GET') { return fail(405, 'GET only') }u = userOfBearer(req.headers['authorization'])if (u == null) { return unauthorizedFor('subscriptions') }md = wantsMarkdown(req)q = req.query != null ? req.query : {}r = subscriptionDelta(route.params.id, u, q.peek == '1', md)if (r.error != null) { return result(r, 200) }return answer(200, md ? r.text : r.data, md)}static removeSubscriptionApi = (route, req) => {if (req.method != 'POST') { return fail(405, 'POST only') }u = userOfBearer(req.headers['authorization'])if (u == null) { return unauthorizedFor('subscriptions') }return result(removeSubscription(route.params.id, u), 200)}
Branches
Latest commits
- e843ff7cOne-time purge of miserit-anthar#94 (#94, identity rule): idempotent step in lib/migrate.hl, fixture gate tests/purge94.mjsmre
- 506a4efdmission 028: #94, identity rulemre
- 78c7f48eRefine mpackdb holdmre
- 3d7d89c8Record mpackdb hold until day38mre
- f1bf7195#51 done; my subscription idmre
- 9870b945status: #51 proof greenmre
- e92173c6log: #51 live push proofmre
- 72d87041log: Hermes push livemre
- 1d69bf7dTickets conductor: park until Hermes pushmre
- 80d8cfd1Tickets conductor: #51 livemre
- 61641dd9Complete subscriptions deployment evidencemre
- c980856cRecord successful subscriptions deployment and live checksmre
- 4b4710adMerge branch 's51-subscriptions'mre
- a731ef7eTickets conductor: S51 reviewed, deploy stepmre
- b487b05aRecord verified direct push protocol handoffmre
- 74e34cc3Verify encrypted push secrets and direct push retry semanticsmre
- a1ac5cd0Push subscription notices directly to signed HyperConductor chat endpointsmre
- d662ad27Remove superseded waker service for direct chat push protocolmre
- c0ac927aTickets conductor: S51 redo for push protocolmre
- ff2e8701Finalize subscription build verification and handoff reportmre