ssc-half-light / .github

Half light social network
https://www.bicycle.codes/halflight
0 stars 0 forks source link

Main feed view #57

Closed nichoth closed 1 year ago

nichoth commented 1 year ago

The view on the home page

Any friend can view your 'friends' collection of posts. This is difficult because it means things work the way they did previously, meaning we need to share our wnfs files at the same time that we add a friend to the DB — need to synchronize state across two systems.


get post path

nichoth commented 1 year ago

shared files


We need to get any posts that a given username has permission to read

Object shape for permissions

{
  username: 'alice',
  permissions: {
    'collection2': {
      users: ['desmond', 'carol'],
      files: [hash2, hash3]
    },
    'my-collection-name': {
      users: ['bob', 'carol'],
      files: [hash1, hash2, ... ]
    }
  }
}

// `permissions.collectionName` here refers to a directory path

So the DB query means

First get your friends, then get the files you are allowed to read for each friend

Must be able to get a file by its collection.


nichoth commented 1 year ago

Query is like

Need to relate a post to a given shareId.

Could keep a shareId next to the post object.

{
  post: {...},
  shareId: 3
}

This means the post author needs to know the shareId for each post.


Users need to track shared folders of their own, so you can add a shareId to every new post.

We have been using post.type to track visibility. Value of either 'friends' or 'private'

Need to start using shareId. Need to keep track of our shareIds, and which folder they correspond to.

Keep a document like

// save at `private/shares.json`
// This is a map of { shareId: pathname }
{
  "1": "/private/friends",
  "2": "/private/coffee-crew"
  "3": "/private/baloney-world"
}

This way when we write a new file to '/private/baloney-world', we can include the shareId in the post message.

nichoth commented 1 year ago

Get any shares that are visible to you

We want any shares that we have accepted

get acceptedShareMessage where username === myUsername

then get any posts by acceptedShareMessage.shareDetails.sharedBy.username, where shareId === acceptedShareMessage.shareDetails.shareId


get the usernames of the acceptedShareMessages use those username to get posts filter the posts, so that post.shareIds includes the shareId in share-msg

nichoth commented 1 year ago

When you make a new post

nichoth commented 1 year ago