---
# System prepended metadata

title: moderator backend test for planetary

---

# moderator backend test for planetary

goal to build a prototype adapter that pulls and sends data to a moderator backend [httpa:here ] via https.

the swift side is a simple CRUD type adapter that sends request to the backend, passing a header and a session key with requests.

I have some dart adapter code I'm using from my flutter client, Atacama, taking a look at that will be helpful in coding the swift version.

#### messages inside moderator payloads

you probably are handling ssb JSON entries to display on planetary. The easiest gig would be to push a bulk of ssb messages into the moderator sandbox,encoded in json, just the way it is. Moderator has no opinion what the payloads contain, I'm putting utf8-text in the payloads there, ssb JSON would go in no problem.

ignoring json message verification I think is in the scope of this trial, might be easier than I think. moderator can store raw bytes so verifier should not explode.

questions from planetary:

_____
# Swift coding tasks

1. http get/post to talk to moderator backend
2. moderatorCapsule binary decoder
3. moderatorCapsuleEntry to ssbEntry adapter

at that point you will get raw json ssb entries (if that's what you want to do) or something that is easy to display on planetary.


questions from planetary:

_______




# Moderator IO
everything is post/get requests over https.
besides the headers all replies are server side gzipped binary to keep things lean.

moderator replies with a session key header and a binary object called *moderatorCapsule* that contains a network key called *katamari* that you post along your request with each POST request you do and you store it in your app to use for the next request.

moderatorCapsule parser, single class in dart in file [xx]


## crud hooks for swift moderator adapter

basically moderator works with the user doing a handshake and receiving a utf8 text *session_key* and *moderatorCapsule* binary blob.

if the user is engaging the first time, handshake with GET, if the account exist on the device, handshake with POST passing the 
*session_key* and *moderatorCapsule.katamari*


### GET

handshake : /
    - say hello to moderator. gives you a http header with *session_key* and a *moderatorCapsule*, binary object you can parse to moderator entries.

### POST
refresh : /
    - give me latest data on moderator instance. send your *session_key* and *moderatorCapsule* to get updates from all the threads on the server.

post message : /new/[moderatorEntryHash]
    - send your *session_key* and *moderatorCapsule* with form data variable ['post'] that contains your utf8encoded payload.
    
reply to message: /reply[moderatorEntryHash]
    - send your *session_key* and *moderatorCapsule* with form data variable ['post'] that contains your utf8encoded payload.



# local database for iOS mobile test

on flutter side, I'm using vanilla dart HiveDB (simple key-val store) that is fast and easy and very compatible. on iOS side you can use whatever you want that is easy to implement.

for this test I think you can skip the DB storage completely if you want and just store the *session_key* and *moderatorCapsule* binary somewhere and retrieve it on app startup and go from there.

# questions from planetary
- does refresh support pagination?
a: refresh (post to domain.com/) gives latest entries that belong together somehow. you store stuff that comes in on a moderatorEntrySet that query that.
you can make swift moderatorEntrySet any way you like. on dart it is an iterable so it can pull scrollview items one at a time

- does refresh support getting a single post?
a: (post to domain.com/t/[key] ) gives you a moderatorEntrySet with entries close to the key. Thread replies and a few other things

- does post allows uploading a blob (i.e. an image)
a: for blob store you can use anything you want and have separate hooks in your code for that. I'm using pinata.cloud IPFS api key to push to ipfs, then receive the cid, then attach the attachment size/xxHash/cid to the posted item.

please note that anything that is over 1 kb has to be an attachment. most ssb messages fit into a small space. longtexts you would put in an attachement then add a link on the moderator entry




______























