FChannel0 / FChannel-Server

GNU Affero General Public License v3.0
105 stars 14 forks source link

Protocol specification? #9

Open MayorUshanka opened 3 years ago

MayorUshanka commented 3 years ago

I'm working on a new type of forum, but it's pretty incompatible with typical "chan" code. However, I want to make it federate with Fchans. It seems you follow this spec: https://www.w3.org/TR/activitypub/#Overview

So what does an incoming "post" from another instance to mine look like?

What does an outgoing "post" from my instance to another look like?

idem dito for a reply.

Do you mirror media, or fetch it from the other instance somehow?

MayorUshanka commented 3 years ago

On my platform:

thread { GUID, title, body, date, capcode, media_url, [array of tags] }

reply { threadGUID, replyGUID, body, date, capcode, media_url }

I imagine I can import remote threads as belonging to just a single tag, like "Technology" or "Random". I can imagine exporting posts and taking the first tag. Or just exporting as "random".

MayorUshanka commented 3 years ago

Another question, how is the fact that on different chans different media types are allowed dealt with?

MayorUshanka commented 3 years ago

Last (probably) question, how is the status of locked/archived threads synchronized?

FChannel0 commented 3 years ago

incoming POST request

{
  "@context": "https://w3.org/ns/activitystreams"
  "type": "Create"
  "actor": "https://fchan.xyz/prog"
  "to": your-website
  "published": "2021-04-19T00:00:00Z"
  "object": {
    "type": "Note",
    "id": GUID,
    "name": title,
    "content": body
    "published": date,
    "attachment" : {
        "type": "Attachment",
        "name": "my-image.jpg",
        "href": media_url,
        "mediatype": "image/jpeg",
        "size": 1084446,
        "published": "2021-04-19T00:00:00Z",
        "updated": "2021-04-19T00:00:00Z",
        "attributedto": GUID,
    }
  }
}

outgoing POST request

{
  "@context": "https://w3.org/ns/activitystreams"
  "type": "Create"
  "actor": your-website
  "to":  "https://fchan.xyz/prog"
  "published": "2021-04-19T00:00:00Z"
  "object": {
    "type": "Note",
    "id": GUID,
    "name": title,
    "content": body
    "published": date,
    "attachment" : {
        "type": "Attachment",
        "name": "my-image.jpg",
        "href": media_url,
        "mediatype": "image/jpeg",
        "size": 1084446,
        "published": "2021-04-19T00:00:00Z",
        "updated": "2021-04-19T00:00:00Z",
        "attributedto": GUID,
    }
  }
}

thread object

"object": {
  "type": "Note",
  "id": GUID,
  "name": title,
  "content": body
  "published": date,
  "attributedto": GUID,
  "attachment" : {
    "type": "Attachment",
    "name": "my-image.jpg",
    "href": media_url,
    "mediatype": "image/jpeg",
    "size": 1084446,
    "published": "2021-04-19T00:00:00Z",
    "updated": "2021-04-19T00:00:00Z",
  }
}

reply object

"object": {
  "type": "Note",
  "id": replyGUID,
  "content": body
  "inreplyto": threadGUID,
  "attributedto": replyGUID,
  "published": date,
  "attachment" : {
    "type": "Attachment",
    "name": "my-image.jpg",
    "href": media_url,
    "mediatype": "image/jpeg",
     "size": 1084446,
     "published": "2021-04-19T00:00:00Z",
     "updated": "2021-04-19T00:00:00Z",
  }
}

When processing incoming or making outgoing POST requests the thread/reply objects are wrapped in an activitystream. You can think of the activitystream outershell as the TCP/IP packet or similar and the thread/reply object as the payload so the activitystream is what it is (Type) whos it from (id) and where its going (to) with the object as the contents being transfered

FChannel0 commented 3 years ago

Do you mirror media, or fetch it from the other instance somehow?

Each instance stores their own media and only the media url is stored in remote instances.

I imagine I can import remote threads as belonging to just a single tag, like "Technology" or "Random". I can imagine exporting posts and taking the first tag. Or just exporting as "random".

That can work, to get the boards (actors) names just make a request with content-type application/activity+json and parse the json to get the boards(actors) prefered name to tag. For example if you make a get request with content-type header application/activity+json to https://fchan.xyz/prog you will get all its information in json form, for summary or tagging purposes

Another question, how is the fact that on different chans different media types are allowed dealt with?

when you parse the json object, with examples above if the "mediatype" is not one you support just ignore it and dont embed it. So above if you parse "mediatype" which is "image/jpeg" and you do not support image/jpeg just ingore the media

Last (probably) question, how is the status of locked/archived threads synchronized?

activitypub objects become tombstoned when they are locked/removed so if you come across and object that is type "Tombstone" you should not allow interaction with it. I am going to add custom object types such as archived and sticky but those are not implemented yet.

let me know if you need more clarification or something expanded upon

MayorUshanka commented 3 years ago

activitypub objects become tombstoned when they are locked/removed so if you come across and object that is type "Tombstone" you should not allow interaction with it. I am going to add custom object types such as archived and sticky but those are not implemented yet.

It seems like instead of a "creation" object, an "activity" object would be perfect for this. I would be interested in the following special states: ('pinned','locked','hidden','archived'), where I think it would be up to the receiving federation to allow foreign pins/stickies.

MayorUshanka commented 3 years ago

Ok, I think I've got something.

other chans: one board per topic, boards are "actors" my chan: one catalog for all topics, threads can be tagged with multiple topics, topics are "actors"

Each actor gets its own I/O endpoint url

Activities: {hidden, revealed, pinned, unpinned, removed, archived, locked, unlocked, edited}

CREATION THREAD [thread origin]

When a native thread is posted:
    for each federation either
        a) for each topic of thread as "board"
            POST thread creation to external "board"
        b) take the first topic of thread as "board"
            POST thread creation to external "board"

When an external thread is received/GET:
    get board of thread as topic. Also add "imported" as topic.
        put thread in db

CREATION REPLY

When on a native thread a reply is posted:
    for each federation either
        a) for each topic of thread as "board"  
            POST reply creation at thread to external "board"
        b) take the first topic of thread as "board"
            POST reply creation at thread to external "board"

When on a native thread a reply is received/GET:
    label reply in database as imported

When on an imported thread a reply is posted:
    get topic of thread as "board"
        POST reply creation at thread to external board

When on an imported thread a reply is received/GET:
    label reply in database as imported

ACTIVITY THREAD

When a native thread is activated:
    for each federation either
        a) for each topic of thread as "board"
            POST thread activity to external "board"
        b) take the first topic of thread as "board"
            POST thread activity to external "board"

When an imported thread is externally activated:
    amend database

When a native thread is externally activated by P:
    cease communications about this thread with P

When a imported thread is locally activated:
    cease communications about this thread globally

ACTIVITY REPLY [reply origin, thread origin]

native, native:
    broadcast activity to every fed for (each topic or first topic)

native, external
    broadcast activity to every fed for (each topic or first topic)

external, native
    amend database

external, external
    amend database