Repository navigation
Add the member list for Liquid (liquid-members.php) - #4
Merged
Merged
Conversation
Liquid fetches the active members from the internal listener, as pgacc does from members.php: TLS, its own token and peer list, 403 or 503 with an empty body. The view liquid_members is built on pgacc_members (same members and LO) and adds eligibility as adm1.php of the old membership system (accredited, and paid or trial month, +30 days, calendar dates only), the email (field 12, or 33 for mitglied@piratenpartei.at; only when eligible; an invalid one is sent as null) and the regions (NUTS codes of postcode fields 4 and 39 from the new table liquid_region_plz: AT130 and AT221, 85 postcodes). The token and peer check moves unchanged from pgacc/members-api.php into lib/internal-api.php, shared by both endpoints. The tests apply the SQL files in the deployment's order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without NO_ZERO_DATE/NO_ZERO_IN_DATE in the SQL mode, values such as 0000-00-00 or 2026-06-00 pass STR_TO_DATE and the format round trip; a zero accreditation date then compared as past and made a paid member eligible. Reject zero components explicitly in fields 35 and 26. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- liquid_region_plz gets the Admidio tables' character set and collation (utf8, utf8_unicode_ci): with another database default the join with adm_user_data failed with "Illegal mix of collations". Tested with a utf8mb3_general_ci database default. - The date comment in liquid_members.sql no longer overclaims (ALLOW_INVALID_DATES); the redundant zero-component guard on field 26 is dropped (adding 30 days to such a value gives NULL; tested). - README: the deliberate difference from adm1.php's email fallback. - tests/grants.sh keeps the pgacc/*.sql glob. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Liquid's member_sync() rejects the whole list for an email that is not a plain local@domain with a dotted domain; PHP's FILTER_VALIDATE_EMAIL also accepts quoted local parts and IP literals. The producer now uses the consumer's regular expression (same pattern, /D for PostgreSQL's end anchor) and sends null otherwise. Tested: quoted local part, IP literal, domain without a dot, trailing newline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behaviour
internal/liquid-members.php(code inliquid/members-api.php) on the existing internal listener, next to pgacc'smembers.php. It replacesadm1.phpof the old membership system (public, shared-key encryption).members.php, with its own secrets file (FastCGI parameterLIQUID_MEMBERS_SECRETS): the socket's address must be in the peer list and the request must carry the bearer token. Otherwise 403, empty body. Any later error: 503, empty body; the log gets only the exception class and code./members.php, and pgacc's by/liquid-members.php.members_api_secretsandmembers_api_allowedmove unchanged frompgacc/members-api.phpintolib/internal-api.php, which both endpoints use. This is a pure refactor;members-test.phppasses unchanged.Data contract
200,application/json, ordered by id:[{"id":1,"lo":38,"eligible":true,"email":"…","regions":["AT130"]}, …]lo: exactly those of the viewpgacc_members;liquid_membersis built on it.eligible(boolean): the rule ofadm1.php. Field 35 must be on or before today, and either field 26 + 30 days ≥ today or field 35 + 30 days ≥ today. Both fields count only as real calendar dates (DATE_FORMAT(STR_TO_DATE(v)) = v, and no zero year, month or day whatever the SQL mode). So "paid until 31 Dec" is eligible through 30 Jan and not on 31 Jan.email: field 12, or field 33 when field 12 ismitglied@piratenpartei.at. It is set only when the member is eligible, otherwisenull. An address outside Liquid's rule is sent asnull, and the member is still listed. The rule is the same regular expression as the consumer'smember_sync()(Member sync from Admidio (replaces getaccounts.php) uniliquid/core#5): a plainlocal@domainwith a dotted domain, no quoted local parts and no IP literals, at most 254 characters. The member stays listed because one such address would make Liquid reject the whole list.regions: the distinct, sorted NUTS codes of postcode fields 4 and 39 (trimmed, exact match) from the new tableliquid_region_plz. Members without one get[].liquid/liquid_region_plz.sqlholds 85 postcodes: AT130 has 23, AT221 has 62. The file is idempotent:CREATE TABLE IF NOT EXISTS, thenDELETE+INSERTin one transaction.pgacc_members.sql→liquid_region_plz.sql→liquid_members.sql. The reader'liquid_members'@'localhost'hasSELECTon the view only. The view isSQL SECURITY DEFINER.Tests
tests/liquid-members-test.phpadds 97 checks, all with synthetic data. The harness mounts../liquid, adds the user tousers.sql, andgrants.shapplies the files in the explicit order above.members.php, plus the cross-endpoint cases in both directions, also through the entry point.adm_*tables,pgacc_members, the accsync view or the region table. pgacc's reader sees neither the Liquid view nor the region table.pgacc_members;01010→[], spaces trimmed, a postcode with two codes → both;Content-Type, and 403 in the refusal cases.tests/run.sh: all three test files pass.liquid_members_api_main()is covered by the entry-point test, which runs in a separate process.2026-12-31x) was added for it. After the switch to the consumer's regex, a second small run on the email lines found that the/Dmodifier (an end anchor like PostgreSQL's) was not pinned by any test, so a trailing-newline test was added. The<= 254check is now load-bearing and tested.Review
Astra found one issue (P2): zero-component dates such as
0000-00-00or2026-06-00passed the check, because the SQL mode has noNO_ZERO_DATE/NO_ZERO_IN_DATE. A zero accreditation date then made a paid member eligible. The regression tests were red first; the fix is in the second commit.Opus review, fixed in the third commit:
liquid_region_plznow has the Admidio tables' collation (utf8,utf8_unicode_ci). Before, the join failed ("Illegal mix of collations") on autf8_general_cidatabase default. A test reproduced this red first.ALLOW_INVALID_DATES.grants.shkeeps thepgacc/*.sqlglob.Astra found nothing on that commit.
Deliberate deviation (email): adm1.php used field 33 only if it had more than 4 characters, otherwise it kept
mitglied@piratenpartei.at. Here a missing or empty field 33 givesnull, so no Liquid account gets the generic address. The comparison with that address ignores case and trailing spaces (the collation). This is documented in the README.⚠ Owner decision needed
Owner decision needed: the 85 postcode→NUTS rows from the old nutsplz table (origin and licence undocumented; plain geographic facts). They come from the old membership system's
nutsplztable, rows AT130 and AT221 only. If they should not be published in this GPL-2.0-only repository, the two lists can be compiled by hand from the Post's public postcode directory before merging.🤖 Generated with Claude Code