fraction / oasis

Free, open-source, peer-to-peer social application that helps you follow friends and discover new ones on Secure Scuttlebutt (SSB).
http://oasis-demo.fraction.io
GNU Affero General Public License v3.0
286 stars 42 forks source link

Oasis shows replies and comments from blocked people #622

Closed nickwynja closed 3 years ago

nickwynja commented 3 years ago

What's the problem you want solved?

The comments on a thread show content from people marked as blocked.

Is there a solution you'd like to recommend?

I've taken a swing at fixing this but I'm all turned around. I've attempted to filter the thread based on the result of models.friend..getRelationship(msg.value.author) but am struggling with JS here.

From models.js:

pullParallelMap(async (message, cb) => {
  // Retrieve a preview of this post's comments / thread
  const thread = await post.fromThread(message.key);
  thread.filter((msg) => {
    models.friend
      .getRelationship(msg.value.author)
      .then((rel) => {
          debug(rel);
          if (rel.blocking == true) {
            debug(msg)
          }
      })
  })
  lodash.set(
    message,
    "value.meta.thread",
    await transform(ssb, thread, myFeedId)
  );
  cb(null, message);
}),

Obviously, I'm just debugging here instead of doing anything practical but every which way I tried to apply this filter didn't work. Happy to keep chipping away on something and open a PR if anyone is able to point me in the right direction.

nickwynja commented 3 years ago

I have a working version by taking a different approach and would some feedback on it. In transform(), I've added a value of value.meta.blocking to each message based on getRelationship(). Then I can use a simple filter:

const t = thread.filter(msg => !msg.value.meta.blocking);

The upside of this is that msg.value.meta.blocking could be used in various places like in the UI. Any downsides to this approach?

Powersource commented 3 years ago

This should have been fixed by https://github.com/fraction/oasis/pull/585 , are you sure you're running latest master?

nickwynja commented 3 years ago

That only fixes not displaying root posts from blocked people. A problem that pops up all throughout Oasis (which I believe @georgeowell has mentioned in the past) is that the socialFilter only applies to the first level of items in the list. Comments/replies/children don't seem to be processed by the socialFilter.

I'm playing a bit more with the blocking attributes in the UI. It might help as a blanket case until we're able to get the queries to filter out consistently. It's a bit hacky but is a start.

image

nickwynja commented 3 years ago

I've opened a #624 to address this. For now, I've left out the filtering mentioned above and am simply replacing the post content with a message instead.