Skip to content

Commit

Permalink
Email settings documentation (#3140)
Browse files Browse the repository at this point in the history
* Email settings documentation

* alerts bug

* test res

* updated doc
  • Loading branch information
grvsachdeva authored and jywarren committed Aug 1, 2018
1 parent 996933c commit dacb01e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ def alert_and_redirect_moderated
flash[:error] = I18n.t('application_controller.author_has_been_banned')
redirect_to '/'
elsif @node.status == 4 && (current_user && (current_user.role == 'admin' || current_user.role == 'moderator'))
flash[:warning] = "First-time poster <a href='/profile/#{@node.author.name}'>#{@node.author.name}</a> submitted this #{time_ago_in_words(@node.created_at)} ago and it has not yet been approved by a moderator. <a class='btn btn-default btn-sm' href='/moderate/publish/#{@node.id}'>Approve</a> <a class='btn btn-default btn-sm' href='/moderate/spam/#{@node.id}'>Spam</a>"
flash.now[:warning] = "First-time poster <a href='/profile/#{@node.author.name}'>#{@node.author.name}</a> submitted this #{time_ago_in_words(@node.created_at)} ago and it has not yet been approved by a moderator. <a class='btn btn-default btn-sm' href='/moderate/publish/#{@node.id}'>Approve</a> <a class='btn btn-default btn-sm' href='/moderate/spam/#{@node.id}'>Spam</a>"
elsif @node.status == 4 && (current_user && current_user.id == @node.author.id) && !flash[:first_time_post]
flash[:warning] = "Thank you for contributing open research, and thanks for your patience while your post is approved by <a href='/wiki/moderation'>community moderators</a> and we'll email you when it is published. In the meantime, if you have more to contribute, feel free to do so."
flash.now[:warning] = "Thank you for contributing open research, and thanks for your patience while your post is approved by <a href='/wiki/moderation'>community moderators</a> and we'll email you when it is published. In the meantime, if you have more to contribute, feel free to do so."
elsif @node.status == 3 && (current_user && (current_user.is_coauthor(@node) || current_user.can_moderate?)) && !flash[:first_time_post]
flash[:warning] = "This is a draft note. Once you're ready, click <a class='btn btn-success btn-xs' href='/notes/publish_draft/#{@node.id}'>Publish Draft</a> to make it public. You can share it with collaborators using this private link <a href='#{@node.draft_url}'>#{@node.draft_url}</a>"
flash.now[:warning] = "This is a draft note. Once you're ready, click <a class='btn btn-success btn-xs' href='/notes/publish_draft/#{@node.id}'>Publish Draft</a> to make it public. You can share it with collaborators using this private link <a href='#{@node.draft_url}'>#{@node.draft_url}</a>"
elsif @node.status != 1 && @node.status != 3 && !(current_user && (current_user.role == 'admin' || current_user.role == 'moderator'))
# if it's spam or a draft
# no notification; don't let people easily fish for existing draft titles; we should try to 404 it
Expand Down
36 changes: 35 additions & 1 deletion doc/EMAIL.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,38 @@ After configurations are done we are good to start the `mailman` server. For sta

> ruby script/mailman_server
Above command will start the server and then the mailman server will do polling in every 60 seconds(which is by default) to check for the incoming mail. However polling time can be changed by setting value to `Mailman.config.poll_interval`(more details can be found at its official [mailman user guide](https://github.com/mailman/mailman/blob/master/USER_GUIDE.md)). Logs for mailman can be seen oin Mailman log file which is present in `log` folder.
Above command will start the server and then the mailman server will do polling in every 60 seconds(which is by default) to check for the incoming mail. However polling time can be changed by setting value to `Mailman.config.poll_interval`(more details can be found at its official [mailman user guide](https://github.com/mailman/mailman/blob/master/USER_GUIDE.md)). Logs for mailman can be seen oin Mailman log file which is present in `log` folder.
3.


## Email Settings

Users can modify **Email Settings** by visiting [https://publiclab.org/settings](https://publiclab.org/settings). Settings for each user are saved by using UserTags on their profiles.
For each setting, there is an associated tag with it. Below is the table showing associated tags with setting.

We consider absence of tag as true and presence of tag as false for setting, so whenever a user turn-off a setting, corressponding user-tag is generated and turning setting on again will delete the tag.
So, while notifying a user UserTag is checked in different files and user is notified depending on the presence or absence of the tag.

| Email Settings | Default | User tag to override default (for turning OFF) | File where tag is used |
| ------------- | ------------- | ----------- | ----------- |
| Notification by email for comments on your posts | ON | notify-comment-direct:false | [app/models/comment.rb](https://github.com/publiclab/plots2/blob/master/app/models/comment.rb#L135) |
| Notification by email for likes on your posts | ON |notify-likes-direct:false | [app/models/node.rb](https://github.com/publiclab/plots2/blob/master/app/models/node.rb#L906) |
| Notification by email for comments on all posts you've commented on | ON | notify-comment-indirect:false | [app/models/concerns/comments_shared.rb](https://github.com/publiclab/plots2/blob/master/app/models/concerns/comments_shared.rb#L24) |


### Digest Settings

Digest settings are a part of **Email Settings** only, but they work a little differently. Digest settings also depend on UserTags.
In case of digest settings, presence of tag marks true and absence of tag as false. There are 2 digest settings currently:

| Digest Settings | User Tag |
| ------------- | ------------- |
| Do you want to receive customized digest weekly | digest:weekly |
| Do you want to receive customized digest daily | digest:daily |

A user can choose only one of the above setting i.e., weekly or daily.

**Relevant Pull Requests:**

[https://github.com/publiclab/plots2/pull/2985](https://github.com/publiclab/plots2/pull/2985)
[https://github.com/publiclab/plots2/pull/3119](https://github.com/publiclab/plots2/pull/3119)

0 comments on commit dacb01e

Please sign in to comment.