Add notification section to docs (#3681)
This commit is contained in:
parent
e9db50b7c9
commit
4f94889524
2 changed files with 26 additions and 0 deletions
25
docs/backend/notification.md
Normal file
25
docs/backend/notification.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: Notifications
|
||||
---
|
||||
|
||||
# Notifications
|
||||
|
||||
Since notifications are run asynchronously, we'll want to make sure jobs are running: `bin/rails jobs:work`. If that's not running, you won't receive any notifications. You might need to create another account to pass notifications back and forth if you're doing this all through the UI.
|
||||
|
||||
Otherwise, you can generate notifications from the Rails console and run the class methods from `app/models/notification.rb`. For example:
|
||||
|
||||
```ruby
|
||||
# follow notification
|
||||
me = User.last
|
||||
follow = User.first.follow(me)
|
||||
Notification.send_new_follower_notification_without_delay(follow)
|
||||
# reaction notification
|
||||
rxn = Reaction.create(
|
||||
user_id: 1,
|
||||
category: "like",
|
||||
reactable: me.articles.last, # this assumes you have an article written
|
||||
)
|
||||
Notification.send_reaction_notification_without_delay(rxn, me)
|
||||
```
|
||||
|
||||
Notice you have to run these methods `without_delay`, since this is assuming jobs are not running.
|
||||
|
|
@ -9,6 +9,7 @@ items:
|
|||
- pusher.md
|
||||
- admin.md
|
||||
- previewing-emails.md
|
||||
- notifications.md
|
||||
---
|
||||
|
||||
# Backend Guide
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue