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

Invites arrive in an invites space, and say nothing of who sent them

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/invites-space
crates/group-host/src/group_invites.rs+4−6
@@ -38,7 +38,7 @@ fn bad(error: &'static str, message: impl Into<String>) -> XrpcError {
/// Someone's inbox: where groups' invites to them arrive.
pub fn inbox_of(did: &str) -> String {
format!("at://{did}/space/{NS}.inbox/self")
format!("at://{did}/space/{NS}.invites/self")
}
fn uri_of(invite: &Invite) -> String {
@@ -224,8 +224,7 @@ pub async fn create_invite(
created_at: now_millis(),
expires_at,
};
let mut record =
json!({"$type": format!("{NS}.invite"), "by": me, "createdAt": iso(invite.created_at)});
let mut record = json!({"$type": format!("{NS}.invite"), "createdAt": iso(invite.created_at)});
if let Some(m) = &invite.message {
record["message"] = json!(m);
}
@@ -331,8 +330,7 @@ pub async fn get_actor_invites(
if let Some(cid) = profile["avatar"]["ref"]["$link"].as_str() {
group["avatar"] = json!(cid);
}
let mut shown =
json!({"group": group, "by": invite.by, "createdAt": iso(invite.created_at)});
let mut shown = json!({"group": group, "createdAt": iso(invite.created_at)});
if let Some(m) = &invite.message {
shown["message"] = json!(m);
}
@@ -381,7 +379,7 @@ pub async fn check_user_access(
));
}
let user = param(&p, "user")?;
let inbox = space.kind == format!("{NS}.inbox");
let inbox = space.kind == format!("{NS}.invites");
let authorized = match p.get("access").map(String::as_str) {
// Its owner reads it; a group here writes in it.
Some("write") => {
crates/group-host/src/lexicons.rs+1−1
@@ -72,8 +72,8 @@ pub const FILES: &[&str] = &[
lexicon!("fyi/opensocial/getViewer"),
lexicon!("fyi/opensocial/importAccount"),
lexicon!("fyi/opensocial/importAccountSpace"),
lexicon!("fyi/opensocial/inbox"),
lexicon!("fyi/opensocial/invite"),
lexicon!("fyi/opensocial/invites"),
lexicon!("fyi/opensocial/label"),
lexicon!("fyi/opensocial/labeler"),
lexicon!("fyi/opensocial/leaveGroup"),
crates/group-host/tests/interop.rs+1−1
@@ -436,7 +436,7 @@ async fn an_invite_into_an_inbox_on_the_reference_pds() {
"com.atproto.space.createSpace",
jwt,
&json!({
"spaceType": "fyi.opensocial.inbox",
"spaceType": "fyi.opensocial.invites",
"skey": "self",
"policy": {"$type": "com.atproto.managedspace.policy", "managingApp": service},
}),
crates/group-host/tests/invites.rs+4−3
@@ -58,9 +58,10 @@ async fn an_invite_is_written_in_the_invitees_inbox() {
.group_record(&did, &inbox, &format!("{NS}.invite"), rkey)
.unwrap()
.unwrap();
// What it says, and no word of who sent it.
assert_eq!(
(record["by"].clone(), record["message"].clone()),
(json!(alice.did), json!("Ride with us"))
(record.get("by"), record["message"].clone()),
(None, json!("Ride with us"))
);
assert_eq!(bob.told.writes.lock().unwrap()[0].1["space"], inbox);
// Asked again, the same one.
@@ -113,7 +114,7 @@ async fn an_invite_is_written_in_the_invitees_inbox() {
// Bob sees his, from the group here.
let (_, mine) = ask(&h, &bob, "getActorInvites", "").await;
assert_eq!(mine["invites"][0]["group"]["displayName"], "Riders");
assert_eq!(mine["invites"][0]["by"], alice.did);
assert_eq!(mine["invites"][0].get("by"), None);
let (_, filtered) = ask(&h, &bob, "getActorInvites", "group=did:plc:other").await;
assert_eq!(filtered["invites"], json!([]));
docs/design/membership.md+2−2
@@ -103,9 +103,9 @@ Details:
An invite must reach someone outside the group, so the group writes it
where they already look: their inbox,
`at://<invitee>/space/fyi.opensocial.inbox/self`, a space of their own at
`at://<invitee>/space/fyi.opensocial.invites/self`, a space of their own at
their PDS. The invite is an `fyi.opensocial.invite` record in the group's
repo there, with `by`, an optional `message` and `expiresAt`. The host
repo there, with an optional `message` and `expiresAt`. The host
answers `com.atproto.managedspace.checkUserAccess` for inboxes: only a
group on this host may write one, and only its owner may read it.
docs/design/spaces.md+1−1
@@ -50,7 +50,7 @@ repo, the space, the revision and that digest.
The group also writes in spaces it is not the authority for. An invite
goes in the group's repo in the invitee's inbox,
`at://<invitee>/space/fyi.opensocial.inbox/self`. The inbox's authority
`at://<invitee>/space/fyi.opensocial.invites/self`. The inbox's authority
asks this host who may use it, with
`com.atproto.managedspace.checkUserAccess`: its owner may read, and a
group here may write ([membership](membership.md)).
harness/lexicons.mjs+2−0
@@ -51,6 +51,8 @@ const retracted = new Set([
'fyi.opensocial.listSpaceRecords#main.output.rev',
'fyi.opensocial.listSpaceRecords#main.output.actors',
'fyi.opensocial.requestJoin#main.input.invite',
'fyi.opensocial.invite#main.record.by',
'fyi.opensocial.getActorInvites#actorInvite.by',
])
const problems = []
lexicons/fyi/opensocial/createInvite.json+1−1
@@ -4,7 +4,7 @@
"defs": {
"main": {
"type": "procedure",
"description": "Write an invite into someone's own inbox (fyi.opensocial.inbox). Requires invite.",
"description": "Write an invite into someone's own inbox (fyi.opensocial.invites). Requires invite.",
"input": {
"encoding": "application/json",
"schema": {
lexicons/fyi/opensocial/getActorInvites.json+0−5
@@ -39,11 +39,6 @@
"type": "ref",
"ref": "fyi.opensocial.defs#groupViewBasic"
},
"by": {
"type": "string",
"format": "did",
"description": "Who in the group sent it."
},
"message": {
"type": "string"
},
lexicons/fyi/opensocial/invite.json+1−6
@@ -5,7 +5,7 @@
"main": {
"type": "record",
"key": "tid",
"description": "An invitation, written by the inviting group into the invitee's own inbox (fyi.opensocial.inbox). The group is the record's author.",
"description": "An invitation, written by the inviting group into the invitee's own inbox (fyi.opensocial.invites). The group is the record's author.",
"record": {
"type": "object",
"required": ["createdAt"],
@@ -22,11 +22,6 @@
"createdAt": {
"type": "string",
"format": "datetime"
},
"by": {
"type": "string",
"format": "did",
"description": "Who in the group sent it."
}
}
}
lexicons/fyi/opensocial/inbox.json → lexicons/fyi/opensocial/invites.jsonrenamed+2−2