Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • Project Forum Project Forum
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 116
    • Issues 116
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 15
    • Merge requests 15
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
    • Model experiments
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • EIPEIP
  • Project ForumProject Forum
  • Project ForumProject Forum
  • Wiki
  • Notifications

Notifications · Changes

Page history
Update Notifications authored Nov 08, 2019 by Taico Aerts's avatar Taico Aerts
Hide whitespace changes
Inline Side-by-side
Notifications.md 0 → 100644
View page @ d534bdd2
# Notifications
Project Forum has the ability to send notifications to users after certain actions.
## Notifications in I18n
Notifications are added to the I18n yaml file as follows.
```
notifications:
resource:
action:
as:
subject: 'Subject of email/notification (Plain)'
message: 'Message of notification (HTML)'
setting_group: 'Group the setting belongs to in the notification preferences (Plain)'
setting: 'Textual description of the notification for the notification preferences (Plain)'
```
| **Item** | **Explanation** | **Example** |
| -------- | --------------- | ----------- |
| resource | the resource for which the notification is sent, plural | projects, groups, thesis_projects |
| action | the (HTTP) action executed on the item | create, destroy, update, import |
| as | the name of the notification itself/the person the notification is for | default, thesis_contact, student |
| subject | the subject of the email/notification. Can contain variables (Plaintext) | '%{user} joined your group' |
| message | the message in the email/notification. Can contain variables (HTML) | '%{coach} accepted your invitation <br> Congratulations!' |
| setting_group | the group under which the notification will be listed in the notification preferences (Plaintext) | Project, Group, Coordinator |
| setting | short text describing the notification as shown in the notification preferences (Plaintext) | Coach accepted invitation |
## Notifications in the code (controllers)
To add notifications to a particular controller, add `include Notifyable` to the controller and define a `send_notifications` method as follows.
```
def send_notifications
log_event(
@project,
nil,
additional_param: some_value,
url: url_to_item
).notify(user_or_list_of_users, as: :something)
end
```
If this function is called from the destroy method, then it will look for all the keys under `projects.destroy.something` or, if that does not exist, `projects.default.something`. It will then attempt to send a notification to `user_or_list_of_users`. If the url parameter is given, the notification on Project Forum will include a clickable link to the given url as `view <name of resource>`.
### Variables
Messages can include variables of the form `%{variable_name}`, which are passed to the log_event method as the additional_param values. Each of these params must have a string value.
## Notification Preferences
Notification preferences are automatically generated from the I18n file. They are listed per `setting_group`, with as text `setting`.
![image](uploads/cedf1e0ce98d2fdc99612302969e1ceb/image.png)
So in the above image, there is a setting:
```
notifications:
groups:
create:
coach:
subject: '%{coach} is now a coach of your group'
message: '%{coach} accepted the request to coach your group "%{group}"'
setting_group: 'Group'
setting: 'Coach accepted invitation'
```
\ No newline at end of file
Clone repository
  • Cleanup after approval
  • Code Quality
  • Database Setup
  • Deployment
  • Elasticsearch Setup
  • Events
  • Home
  • Installation on Windows
  • Interesting features
  • Notifications
  • Overview of notifications
  • SAML
  • Thesis Workflow