Skip to content

Commit

Permalink
Run the extra app-side comment filter only if the claim is not ours.
Browse files Browse the repository at this point in the history
## Preamble
- The app-side uses a cached blocklist, so when a Timeout expires, it doesn't know that the ban has been lifted.
- Meanwhile, we are doing extra comment filtering using this blocklist (so that we don't see comments that we have blocked, regardless of whose claim we are viewing).

## Issue
In a livestream, if a new message from an ex-offender comes in after their ban has been lifted, we do get the websocket message but it's being filtered out locally as mentioned above. So, the msg ended up being visible for everyone except the owner.

## Fix (band aid)
- Don't run the extra filter if the claim we are viewing is ours -- commentron would have filtered it for us anyways, and is the right logic to use even before this Timeout feature is introduced.
    - For the case of Timeout, this only serves as a band-aid until Commentron Issue 80 is available for us to detect the ban has been lifted. This is because it doesn't handle the case where I am a viewer and I decided to timeout someone for a few minutes. Because I am not the owner of the claim, the offender will continue to be blocked due to the same issue mentioned above.
  • Loading branch information
infinite-persistence committed Sep 3, 2021
1 parent 804edd3 commit bf8ab2e
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions ui/redux/selectors/comments.js
Expand Up @@ -214,7 +214,7 @@ export const makeSelectCommentsForUri = (uri: string) =>
(state, byClaimId, byUri) => {
const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId];
return makeSelectFilteredComments(comments)(state);
return makeSelectFilteredComments(comments, claimId)(state);
}
);

Expand All @@ -226,7 +226,7 @@ export const makeSelectTopLevelCommentsForUri = (uri: string) =>
(state, byClaimId, byUri) => {
const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId];
return makeSelectFilteredComments(comments)(state);
return makeSelectFilteredComments(comments, claimId)(state);
}
);

Expand Down Expand Up @@ -262,7 +262,13 @@ export const makeSelectRepliesForParentId = (id: string) =>
}
);

const makeSelectFilteredComments = (comments: Array<Comment>) =>
/**
* makeSelectFilteredComments
*
* @param comments List of comments to filter.
* @param claimId The claim that `comments` reside in.
*/
const makeSelectFilteredComments = (comments: Array<Comment>, claimId?: string) =>
createSelector(
selectClaimsById,
selectMyActiveClaims,
Expand Down Expand Up @@ -315,12 +321,18 @@ const makeSelectFilteredComments = (comments: Array<Comment>) =>
}
}

return !(
mutedChannels.includes(comment.channel_url) ||
personalBlockList.includes(comment.channel_url) ||
adminBlockList.includes(comment.channel_url) ||
moderatorBlockList.includes(comment.channel_url)
);
if (claimId) {
const claimIdIsMine = myClaims && myClaims.size > 0 && myClaims.has(claimId);
if (!claimIdIsMine) {
return !(
personalBlockList.includes(comment.channel_url) ||
adminBlockList.includes(comment.channel_url) ||
moderatorBlockList.includes(comment.channel_url)
);
}
}

return !mutedChannels.includes(comment.channel_url);
})
: [];
}
Expand Down

0 comments on commit bf8ab2e

Please sign in to comment.