oliver-zehentleitner / maity
clean-up: G7 joining and notification routes: one text rule, one mail-link page builder, a key cursor for orgs, the card watch out of notifications
tsk-mm3dk7hwfm74 Open
From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G7 sign-in, joining, landing and notification routes), read at 9dfd4b65. Every line number is at 9dfd4b65. Paths are under hub/src/maity_hub/.
The module code of areas 10 and 12 is on tsk-04gvgb2h7xzr, tsk-hz5nkwyn9sj9, tsk-8vdegd61y70v and tsk-xx108ajy287x. This card is the route layer (routes/invitations.py, routes/orgs.py, routes/notifications.py, routes/mail_links.py, routes/email_sign_in.py).
1. Duplication: "no control character but a line break or a tab" three times
- Kind: duplication.
- Files:
routes/invitations.py:68-72(the invitation'snote),routes/registration.py:403-404(the rejectionreason),auth/second_factor_reset.py:62-66(the resetreason). All three writeany(ord(c) < 32 and c not in "\n\t" or ord(c) == 127 for c in value). - Proposal: one helper for multi-line plain text (for example
plain_text(value, multiline=True)beside the display-name rule of tsk-hz5nkwyn9sj9 item 10, which is the single-line form), used by the three. - Effort: S. Risk: none.
2. Design: GET /admin/orgs puts a fake time into its cursor
- Kind: design.
- Files:
routes/orgs.py:92-95buildspaging.cursor(clock.now(), items[-1]["handle"], bound)and reads back only the second part (:88). Its comment says "the timestamp slot only has to be a time".paging.py:33-45has only the (time, id) cursor andkey_cursorfor the card order. - Proposal: a key-only pair in
paging.py(for exampleafter_key(key, bound)/read_key(text, bound)), used here. - Effort: S. Risk: low (old cursors stop working once, which the alpha allows).
3. Debt: _filters has a parameter no caller uses
- Kind: dead code.
- Files:
routes/notifications.py:94-100takesallowed; both callers passNone(:129,:130). - Proposal: drop the parameter and its branch.
- Effort: S. Risk: none.
4. Duplication: every mail-link page reads its token twice or three times
- Kind: duplication, small slow path.
- Files:
routes/mail_links.py:62-68(_language) verifies the token to find the language;verify_pageverifies it again at:82andunsubscribe_pageat:130; thePOSThandlers pass it topreferences.verify(:117),preferences.unsubscribe(:161),second_factor_reset.take_effect(:203) andaccount_deletion.confirm(:242), which verify it once more. - Proposal: read the token once per request and pass the payload to
_languageand to the page code. - Effort: S. Risk: none.
5. Duplication: two builders for the pages a mail link opens
- Kind: duplication, design.
- Files:
routes/mail_links.py:32-59(_page: title, text, quote, onePOSTbutton, wrapped in<div class="link-page">) androutes/email_sign_in.py:290-296(_dead) and:319-332(the sign-in link page), which build the same HTML by hand without the wrapper. Both end inlink_frame.page. public-pages.css:63-66 styles.link-page, so the sign-in link pages look slightly different from the other mail-link pages. - Proposal: move
_pageintolink_frame(for examplelink_frame.link_page(..., hidden=None)with an optional hidden form field) and use it from both modules. - Effort: S. Risk: low (the sign-in link page's HTML changes; the tests check its text).
6. Design: the card watch routes live in the notification routes
- Kind: design (module past its purpose).
- Files:
routes/notifications.py:402-445(PUTandDELETE /projects/{owner}/{slug}/tasks/{id}/watch). Their own docstring (:416-418) says a watch notifies nothing (§6.4, §18.1). The domain side iscard_watches.py. - Proposal: move the two routes to a small
routes/card_watches.py(or next to the other card routes) and register it inapp.py. - Effort: S. Risk: none.
Order
- Item 1 together with tsk-hz5nkwyn9sj9 item 10, so the single-line and multi-line rules land in one place.
- Item 5 touches
routes/email_sign_in.py, which the companion card "clean-up: G7 sign-in routes: one sign-in completion …" (item 5) also moves; rebase rather than conflict.
Instances of hub-wide cards (not filed again)
routes/invitations.py:386, the inline 409project_closed: already listed on tsk-p3a14j8p1rg9.org_projects.py:130,from maity_hub.routes.members import Change, apply_remove: already listed on tsk-dwrtrhdgzezs.
Covered elsewhere
- The TODO at
routes/invitations.py:383-384(accept only from a session in good standing; such sessions exist now): tsk-vk79jr6gsexm. routes/invitations.py:318-321, the registration settings resolved inline: item 6 of the companion sign-in card.- The per-owner caps in
orgs.create(routes/orgs.py:70-71): tsk-5sfts81hr516.
Effort sum: 6 S.