-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude posts in own subs from spam detection #1946
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You found the right spot to fix #787!
I think it's almost there, but I found a bug regarding replies, see comment.
Will review more later, but I wanted to mention this before I go to lunch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that since this filters out posts from own territories, it will still apply the spam fee to posts in your own territories if you posted before in other territories.
I think stackers will expect that they never have to pay the spam fee in their own territories. For this, we need to also pass subName
to item_spam
so we can check if we want to create a post in one of our own territories. If that is the case, we immediately return 0. That should also make the item_spam
function easier to read and thus less prone to bugs.
Does this make sense?
Yes, I agree that's what the territory owner would like, ideally. It's also a more invasive change. The middle ground would be better than nothing (the territory owner is unlikely to spam others' territories). |
It's a bigger change, yes, but as-is, this does not fix #787 because a territory founder can still pay 10x in their own territories. For that to happen, they only need to post in another territory once and then they will pay 10x in their own territory for the next 10 minutes. I don't consider this to be an edge case. |
What I slightly dislike is how the additional parameter will change the semantics of the function. Right now, the function tells you how badly a particular user has spammed in the interval. A territory owner who has spammed a foreign territory and subsequently wants to post in his own territory without penalty at the same time
So the function now returns two different kinds of information. |
To play devil's advocate: If territory owners should be able to post to their territories for base cost (no matter how much they spammed), shouldn't the same apply to any user posting their bio (the existing exclusion AND bio = 'f'), too? Right now, posting your bio doesn't increase the spam counter, but when you have otherwise spammed before, your cost of posting bio multiplies. Maybe the function should continue to answer only the question "how much has the user spammed in the interval" (where bio posting and territory owner posting in own territories are not spam), but the caller should not always do the POWER multiplication (posting should only do it if the user is not the owner, bio posting should never do it)? |
Sorry for the late reply.
What we want for #787 is to never make founders pay spam fees in their territory. Everything else is secondary and can be updated accordingly.
This is a great point! Bios should not affect spam fees ( ✅ ) and not be affected by them ( ❌ ). |
Now I'm passing sub into item_spam() to return 0 for the owner. I tested the following sequence: Login as unrelated user
Login as user who owns sub 'AGORA'
In short, the behaviour is now as before, except for two things:
I believe that's what you asked for. I wasn't exactly sure if any of the parameters should have been named subName instead of sub, there may be naming conventions to the layers that I mixed up, should be cosmetic, but let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a full review yet because I found some issues just from looking at the code. Will continue review when they are fixed.
@@ -71,7 +71,7 @@ export default forwardRef(function Reply ({ | |||
// no lag for itemRepetition | |||
if (!item.mine && me) { | |||
cache.updateQuery({ | |||
query: gql`{ itemRepetition(parentId: "${parentId}") }` | |||
query: gql`{ itemRepetition(parentId: "${parentId}", sub: "${sub?.name}") }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this as-is, assuming that was a hint how to solve the other comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that you have the same issue with searching for updating the query with a sub named 'undefined' here, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prisma/migrations/20250314104901_pass_sub_to_item_spam/migration.sql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but the code can be improved, see my two comments.
const query = parentId && sub | ||
? gql`{ itemRepetition(parentId: "${parentId}", sub: "${sub}") }` | ||
: (parentId | ||
? gql`{ itemRepetition(parentId: "${parentId}") }` | ||
: (sub | ||
? gql`{ itemRepetition(sub: "${sub}") }` | ||
: gql`{ itemRepetition }` | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the other comment, this should use GraphQL variables.
@@ -71,7 +71,7 @@ export default forwardRef(function Reply ({ | |||
// no lag for itemRepetition | |||
if (!item.mine && me) { | |||
cache.updateQuery({ | |||
query: gql`{ itemRepetition(parentId: "${parentId}") }` | |||
query: gql`{ itemRepetition(parentId: "${parentId}", sub: "${sub?.name}") }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Fix #787
Modify SQL function item_spam to ignore posts made in own subs:
I tested by running the replaced function through ./sndev psql and
stackernews=# select item_spam(NULL, 15556, interval '1' hour);
And testing by posting as territory owner in the web interface.
Note that this will only ignore posts made by a territory owner in their own subs. Posts made in others' subs still count. As they should, IMO.