grishka / Smithereen

Federated, ActivityPub-compatible social network server with friends, walls, and groups.
The Unlicense
393 stars 31 forks source link

Groups: add capabilities ("acceptsJoins": true) #26

Closed alexgleason closed 3 years ago

alexgleason commented 3 years ago

My groups implementation deals with both Follow and Join, but they do different things. It would be nice to know if a remote group can accept Joins, and if not I can send a Follow instead.

I added a "capabilities" map to the Group actor (this is from litepub, Pleroma's LD namespace: https://lain.com/schemas/litepub-0.1.jsonld

The typical format for capabilities values are booleans like "acceptsChatMessages": true, so I've introduced "acceptsJoins": false

The result:

➜  Smithereen git:(groups-capabilities) ✗ curl -H 'Accept: application/activity+json' https://smithereen.ngrok.io/soapbox-dev | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1504    0  1504    0     0   3876      0 --:--:-- --:--:-- --:--:--  3866
{
  "type": "Group",
  "id": "https://smithereen.ngrok.io/groups/1",
  "name": "Soapbox Dev",
  "url": "https://smithereen.ngrok.io/soapbox-dev",
  "preferredUsername": "soapbox-dev",
  "inbox": "https://smithereen.ngrok.io/groups/1/inbox",
  "outbox": "https://smithereen.ngrok.io/groups/1/outbox",
  "followers": "https://smithereen.ngrok.io/groups/1/followers",
  "endpoints": {
    "sharedInbox": "https://smithereen.ngrok.io/activitypub/sharedInbox"
  },
  "publicKey": {
    "id": "https://smithereen.ngrok.io/groups/1#main-key",
    "owner": "https://smithereen.ngrok.io/groups/1",
    "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg6NI5j0mpOYKsHMUF0UhnbicGTqvlvmWKa3NHqCNhjeknOwufSVc5pslUWjUZ2dDEDciw3GBWlY+Yq5GpTcZVIiOqIO7dAxPbwvR4TaOnkjZeBjKoS+wm3aO2OvhUpzU4eNwERwEL/aAVNiQ81a1S7l3YyMkzsv0iR317PAojbnyAeXOjO7AjsYSRCzaqfmCdvlDtElSvFhY7ShDnfJ8UPITGvwNlfBJab1JRRxnyv06Uy+uy9j5uFYDUZLl0HqVR2gygnPSYdW9EcoLl33oKQc2wOlhl1wdgnQgpToVRWJxjCLUVmBMzEMHSHOiv6rRDrhysqSHMgxrjrpnVS7/KwIDAQAB\n-----END PUBLIC KEY-----\n"
  },
  "wall": "https://smithereen.ngrok.io/groups/1/wall",
  "attributedTo": [
    {
      "type": "Person",
      "id": "https://smithereen.ngrok.io/users/1"
    }
  ],
  "members": "https://smithereen.ngrok.io/groups/1/followers",
  "capabilities": {
    "acceptsJoins": false
  },
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    {
      "wall": {
        "@id": "sm:wall",
        "@type": "@id"
      },
      "sm": "http://smithereen.software/ns#",
      "members": {
        "@id": "sm:members",
        "@type": "@id"
      },
      "capabilities": "litepub:capabilities",
      "litepub": "http://litepub.social/ns#"
    },
    "https://w3id.org/security/v1"
  ]
}
grishka commented 3 years ago

I actually do accept Join, as an alias for Follow

alexgleason commented 3 years ago

Well shit, even better. I still need to know, so I set it to true instead of false.