-
Notifications
You must be signed in to change notification settings - Fork 932
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
display an encouragement to contribute after many anonymous notes #5468
display an encouragement to contribute after many anonymous notes #5468
Conversation
If they're valid notes I don't really see the problem? Are these genuine notes or is this some sort of spam attack? |
I'd store the counter in a cookie, set an expiration date for that cookie to something like a week and replace the existing "You are not logged in" alert with this more motivating one with a note counter server-side. |
A large part of them are not valid or useless. This PR should not be seen as a way to solve a one guy problem, but a global issue with anonymous notes. The lack of communication channel makes a lot of them difficult to deal with, so at least when someone is creating a lot of notes, we should push to create that communication channel, and it also a way to avoid spam. |
I am not a specialist of cookies VS localStorage, the only advantage of cookies is the possibility to set an expiration date ?
good idea!
I'm not sure I understood this part. I imagined this would require storing an ‘anonymous visitor ID’ in the cookie and creating a table on the server to associate this ID with the notes created by the visitor? but maybe I've misunderstood? |
The browser sends cookies to the server. It doesn't send localStorage. If the server knows the counter value, it can display another message based on that value, that's what I mean by:
|
This thing already exists as session id in
That request will increase the counter stored in session if necessary. After that app/views/notes/new.html.erb or its controller can check the counter value and display the message based on that.
All of this depends on how soon our sessions expire. The example in #5468 (comment) shows a 10-minute burst of activity, so the session doesn't have to live for very long. |
5250276
to
6e6000c
Compare
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're adding things like var anonymousNotesCount = Number(localStorage.getItem("anonymousNotesCount"));
in your first commit, then you completely remove them in the second. In this case you can just squash these commits together.
Good idea, I'll do that, it'll be cleaner. Sorry, I'm not really used to PR so I hadn't thought of it myself. |
What shall we do with the counter
|
I thought about it, we could delete the cookie after logging in, but it seemed pointless as the cookie will expire 30 days after the last anonymous note anyway. Do you agree? |
The point could be that if I log in my session may expire faster than that and I'll se the message again. But maybe it's not worth doing anything about it. |
6e6000c
to
13d1113
Compare
Hi,
|
If you do this, you probably also want to delete the cookie on signup. I'm not sure if it's better to do before or after confirming the email. If before, you'd delete the cookie somewhere here:
|
13d1113
to
b49cdc1
Compare
create a counter of anonymous notes in a cookie, read by new note controller to display an encouragement to contribute in the already existing anonymous warning if the anonymous visitor has already created at least 10 anonymous notes. Cookie deleted on log-in and sign-up after email validation
b49cdc1
to
0f2df0b
Compare
Merged, thanks! I pushed some whitespace changes to satisfy erblint test. That test didn't run because it needed approval, so you couldn't see it here. |
Motivation
In the French community, we've had a problem for over a year with someone creating a huge number of anonymous notes, which hampers the processing of other relevant notes in the same area. See this discussion on the French community forum.
I thought it would be a good idea to count the number of anonymous notes created in the same browser and to display a warning when this number becomes too high, to encourage visitors to become users and contributors.
Description
This PR creates a new warning in the UI of the new note form if an anonymous visitor has already created too many anonymous notes (threshold set at 20 for now)
Changes:
Possible additional change (not included yet)
After an even larger number of anonymous notes (50?), I thought we could hide the textarea, and trigger its display by clicking on a button sure you want to post an anonymous note again?, which would force the visitor to perform an additional action. This is not included in this PR yet, but tell me if you want me to add it.
How has this been tested?
The code has been tested on my personal computer using rails built-in webserver. I verified that the new note form is still working fine both when logged in and in anonymous mode.
However, as described in issue #5467 I was not able to make all the tests requested in CONTRIBUTING.md.
As this is my very first PR, I'm not sure I've done everything right, so I welcome any relevant comments!