~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

A group's profile, images and rules are changed by those who may configure it

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/group-config

What changes

A group's face can be changed by whoever holds group.configure. These are new methods in group_config.rs:

  • fyi.opensocial.updateProfile replaces the profile:
    • Where it meets, whether online, topics and languages: as given, and none when left out. Topics are trimmed, deduplicated, at most ten, and 64 characters each. Languages are BCP 47 tags, at most five. A location must be one of community.lexicon.location's.
    • The site, avatar and banner: kept when left out. null clears an image.
    • The join policy: kept unless named, in either the profile's words or the method's.
    • Its first createdAt: kept.
  • fyi.opensocial.uploadImage keeps an image of up to 1 MB as the group's blob and answers the reference to put in the profile.
  • fyi.opensocial.putRule makes or changes a rule:
    • A changed rule keeps its key, place and creation time. order moves it.
    • A new rule goes last, under a fresh key or the one named.
  • fyi.opensocial.deleteRule takes a rule away. Deleting one that isn't there is no error.

The group test helpers move into tests/common/groups.rs. docs/design/groups.md gains "Changing its face", and the plan marks this part done.

Why

This is the next part of 4d, following the prototype's methods/profile.ts and methods/rules.ts. These records are written by the group, so an admin can't write them directly. The host writes them after checking the caller's actions against the permissions record.

Changes from the prototype:

  • The new rule key is a TID rather than random hex.
  • Lists are of objects ([{topic}], [{language}]), as this host's lexicons have them.
  • There is no blob re-normalising beyond reading {ref, mimeType, size}: this host never sees the BlobRef instances the prototype had to repair.

How it was checked

tests/group_config.rs covers:

  • An admin's update:
    • every field, and the trimming and dropping of bad topics and languages;
    • the uploaded avatar, and the kept createdAt;
    • the replace keeping site and images and dropping what finds the group;
    • null clearing an image.
  • Every refusal:
    • a plain member, a stranger, or no auth;
    • no group, an unknown group, a blank name, a bad policy, an unknown place;
    • a malformed blob, or a blob that isn't the group's;
    • uploads that are empty, over 1 MB, from a non-admin, or not a POST.
  • Rules:
    • new ones go last;
    • edits keep their key, place and time; moved, named, and deleted twice;
    • every refusal.

just cov is at 100% of lines and functions, and clippy is clean.

Shortcomings

  • Images aren't checked to be images: the type is the uploader's word, as in the prototype.
  • Changing a rule's order doesn't renumber the others.

🤖 Generated with Claude Code

Approved

This adds updateProfile, uploadImage, putRule and deleteRule in group_config.rs. Each is gated on group.configure, checked against the group's permissions record. The routes are wired, the lexicons for these methods already exist, and docs/design/groups.md and the README plan are updated. I read the whole diff but did not run the checks.

  • Permissions: configurer signs the caller in, checks the group exists, then checks the action. The tests cover a member, a stranger and no auth.
  • Profile: the semantics match the body: join policy, createdAt and site are kept, and images are kept unless null is given. Topics and languages are bounded as described.
  • Rules: edits keep their key, place and creation time, and a new rule goes last. order moves a rule.

Two small things, neither blocking:

  • put reads the record and then picks Create or Update. Two concurrent calls for the same key could both choose Create, and the second would fail with whatever error space_write gives. That is rare for an admin-only method.
  • putRule takes a caller-supplied rkey as given. I assumed space_write or the record layer rejects an invalid key, and I did not check that. A one-line test with a key like a/b would confirm it.
Merged as 2a15682