Commit graph

78 commits

Author SHA1 Message Date
Vaidehi Joshi
8f0c24c167
Expand @-mention functionality to posts (#13367)
* Initial work for @-mention notifications from posts

* Revert article.published changes to article updater, add clarifying comments

* Extract article preview into reusable partial for notification views

* Clean up Article Updater

* Address + remove some FIXMEs

* Add a whole buncha specs for @-mention functionality in posts YAY

* Refactor create all spec to use shared examples, add clarifying comments

* Add guard clause to create all service

* Update new mention and notifiable action specs

* Some additional cleanup

* Add specs + shared examples to SendEmailNotificationWorker spec

* Use aggregate_failures where applicable

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Cleanup and address code review comments

* Add MentionDecorator + relevant specs

* Address comments/issues flagged by @rhymes

* Optimize plucking user_ids when checking for article followers

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-05-12 07:33:33 -07:00
rhymes
2d881ef571
Routine rubocop fixes (#10237) 2020-09-08 12:06:47 -04:00
rhymes
085c60992b
Rubocop: Enable and fix Style/OptionalBooleanParameter cop (#9711)
* Enable and fix Style/OptionalBooleanParameter cop

* Keep regular parameters for workers

* Keep regular parameters for workers

* Fix spec

* Trigger Travis correctly
2020-08-10 19:35:55 +02:00
Molly Struve
a16fc46f84
[deploy] Revert "Async Handle Notifications for Comments When Saved (#9680)" (#9686)
This reverts commit 852223dd86.
2020-08-08 20:16:27 -05:00
Molly Struve
852223dd86
[deploy] Async Handle Notifications for Comments When Saved (#9680) 2020-08-08 17:59:17 -05:00
Molly Struve
dba270f02e
[deploy] Optimization: Default Delete Notifications Older than 3 months (#9038) 2020-06-30 16:15:21 -05:00
Molly Struve
33b68d4b39
Flaky Spec/Bug Fix:Dont Send Mod Notification if No Commentable (#8869) 2020-06-23 17:22:34 -04:00
Molly Struve
699f9c8144
[deploy] Optimization:Use Scope and current_user to Get Notification Count (#8177) 2020-06-01 09:27:46 -05:00
Vaidehi Joshi
f71c8b16e7
Allow dynamic authoring of welcome notifications (#6045) [deploy]
* Add "Welcome" type to Broadcasts, allow dynamic "authoring" of Broadcasts

This adds a new `type_of` to the Broadcast model: "Welcome". As we begin to create a new "welcome notification" workflow, we'll categorize them by making them all of the same type.

This also adds a concept of a "welcoming user", which can be set via an ENV var. The WELCOMING_USER_ID will allow us to explicitly set (and change) which user in the database is the one that "sends" welcoming notification. In production, we plan for this to be dev.to/sloan.

* Allow WelcomeNotificationWorker to accept + send any kind of broadcast

This abstracts out the logic of deciding which broadcast to send from the woker into the calling method. This will help us send many different kinds of welcome notifications using one, resuable worker class.

* Raise if a Notification can't be created

* Add STAFF_USER_ID as an ENV var

This is in preparation for moving away from SiteConfig.staff_user_id, and replacing it with an ENV var. We will need to set this in production first, and then make a separate PR to replace all instances of staff_user_id with the newly-set ENV var.
2020-02-12 13:50:37 -08:00
Alex
6a100415cc
Move Notifications::TagAdjustmentNotificationJob to Sidekiq (#5909) [deploy]
* Create TagAdjustmentNotificationWorker

* Create TagAdjustmentNotificationWorker spec

* Update references and specs for new worker

* Future proof specs
2020-02-05 09:52:21 -08:00
Lucas Hiago
d5a5c53419 Change Notifications::UpdateJob to Notifications::UpdateWorker and move to sidekiq (#5689) [deploy] 2020-01-28 12:43:50 -05:00
Lucas Hiago
ca0770dbdd Remove Notifications::RemoveAllByActionJob and Handle inline (#5690) 2020-01-28 12:43:21 -05:00
Lucas Hiago
587d1040dc Change ModerationNotificationJob to ModerationNotificationWorker and move to sidekiq (#5683) [deploy] 2020-01-28 08:42:26 -05:00
serena
1297f1cb3e Replace Notifications::NotifiableActionJob with Notifications::NotifiableActionWorker for Sidekiq (#5588) [deploy] 2020-01-22 09:40:55 -05:00
rhymes
adfe1fac73 Optimize Notifications::Update and it specs (#5417) 2020-01-20 16:55:50 -05:00
Dainius Stankevicius
8c43c3d484 Utilize NewComment::Send in Notification model (#5565) [deploy] 2020-01-20 16:38:42 -05:00
Alex
e1e075479b Create new NewFollowerWorker and start sending jobs to it (#5556) [deploy] 2020-01-17 15:08:50 -05:00
Lucas Hiago
97aac4ef9b Change Notifications::MilestoneJob to Notifications::MilestoneWorker and move to sidekiq (#5454) [deploy] 2020-01-15 13:21:56 -05:00
Lucas Hiago
74f9decc56 Change Notifications::RemoveAllJob to Notifications::RemoveAllWorker and move to sidekiq (#5451) 2020-01-15 12:34:12 -05:00
serena
6e9539415e Move welcome notification job to worker for Sidekiq (#5465) [deploy] 2020-01-13 13:28:23 -06:00
Molly Struve
5e6ca69e27
Check for follow before trying to send a notification (#5438) [deploy] 2020-01-10 13:59:38 -06:00
Nick Schwaderer
74da1ffc59 No longer hide reactions and follows after 24 hours (#5314)
* No longer hide reactions and follows after 24 hours
* Removes unused scope without_past_aggregations

Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-01-09 11:49:55 -05:00
Mukesh Chaudhary
48edaab5bc Migrate new reaction job 5305 (#5401)
* Add New Reaction Worker

* Add Specs for the New Reaction Worker

* Update Worker Calls in Notification Model

* Update Notification Model Specs

* Fix Code Climate Issues

* Fix notification specs to remove instance variable and complex logic

* Fix Worker Spec

* Fix Review Comments

* Undo Job Specs

Co-authored-by: Mukesh Chaudhary <45253983+mukeshchdy@users.noreply.github.com>
2020-01-09 09:51:56 -05:00
serena
252027ad9c use new_badge_achievement_worker instead of active job (#5358) [deploy] 2020-01-07 08:16:17 -05:00
serena
51df32552c Change MentionJob to MentionWorker and move to sidekiq (#5312) [deploy] 2020-01-02 07:57:08 -05:00
Molly Struve
49545ae41f
Use SQL DELETE statement to delete notifications without a SELECT (#5303) [deploy] 2019-12-31 07:30:27 -06:00
Molly Struve
f86f93bc8a
Create rake Task to Destroy Old Notifications (#5180) [deploy] 2019-12-26 13:17:34 -06:00
rhymes
9c05e618db Improve speed of model tests by around 50/60 seconds (#5016) 2019-12-09 16:33:48 -05:00
Andy Zhao
73caa9a864 New Feature: Block Users (#4411)
* Prevent need for eager loading

* Add initial implementation of user block

* Remove debugger oops

* Add index and foreign keys for user_block table

* Use private method instead of exists

* Move channel handling logic to service object

* Update styling a bit

* Use profileDropdown file for future proofing

* Remove commented out code

* Render json: { result } for all endpoints

* Add statuses for sad paths

* Add better sad path handling in the JS

* Remove accidentally committed spec file

* Don't wait for DOM to load block button

* Use equality for accuracy in slug query

* Add status code for unauthorized requests

* Add missing comma sigh
2019-10-23 17:14:28 -04:00
Araslanov Evgeny
02a75b6efa Remove unused methods _without_delay (#4366) [ci skip] 2019-10-16 10:35:49 -04:00
Andy Zhao
3b0f6f2834 Refactor remove_all and remove_each notifications and fix orphaned notifications (#3570) 2019-09-25 15:31:56 -04:00
Ben Halpern
590149fd48
Fix notifications past aggregation query (#3998) 2019-09-10 11:27:23 -04:00
rhymes
80e6cf4801 Notifications: increase efficiency and fix pagination offset issue (#3986)
* Increase efficiency and fix pagination offset issue

Right now we filter recently aggregated notifications at runtime, which worked before when there was no pagination, but now filtering is not a good idea combined with offset pagination because it throws off the calculations.

The filtering should be done in the SQL query before paginating, which is what we've switched to. I added a bunch of scopes to make the code clearer as well.

To avoid nesting tags I've also updated the HTML and the JS logic to insert it in the right place.

* Add explanation for hiding the load more button for new users
2019-09-10 09:43:45 -04:00
Jacob Herrington
099b188530 Rename uncommunicative variables (#3890)
* Clarify uncommunicative variables in labor classes

Single letter variable names are largely a question of preference, in
some cases I think that convention mitigates the opaque nature of single
letter variable names (e.g., e for error, i for index, etc).

However, in some cases they can be unclear and there isn't much reason
to use single letter variables unless for some reason character length is
really important.

In this case, I would prefer clarity in variable names over brevity of
code so I've used Reek to identify short variable names and I'm changing
them.

It's pretty boring, but hopefully incremental code love changes like
this one add up and improve readability and accessibility for those
interested in reading this codebase.

* Remove commented code from 2 years ago

* Clarify uncommunicative naming in services classes

There is some context for this change in 6b81880f

* Clarify uncommunicative naming in models

There is some context for this change in 6b81880f

* Clarify uncommunicative naming in liquid_tags

There is some context for this change in 6b81880f
2019-09-02 13:05:07 -04:00
Anna Buianova
f9da88b006 Moved send_mention_notification to ActiveJob (#3566) 2019-08-01 16:35:25 -04:00
cyrillefr
8c52d5c43f Move remove_each notifications method in own job (#2946) 2019-05-29 16:26:18 -04:00
Anna Buianova
a6091fe6c8 Moved notifying followers to a separate ActiveJob #1996 (#2935)
* Moved notifying followers to a service + specs

* Created an ActiveJob for notifiable action notifications

* Call the job from the Notification#send_to_followers

* Refactor creating notifiable action notification

* Handle possible nil followers while sending notifiable action notification

* Use activerecord import to bulk-create notifications

* Set notified_at for the bulk-created notifications

* Move compact to the appropriate place
2019-05-24 07:45:51 -04:00
cyrillefr
abb4831a53 Move remove_all notifications method in own job (#2882)
- that calls a service
    - spec for job + service
    - check actual integration spec
    - minor refactoring
2019-05-20 13:54:39 -04:00
rhymes
7f28a0e44b Unpack milestone hash (#2860) 2019-05-16 22:54:57 -04:00
cyrillefr
68f06c2076 send_milestone_notification in own job (#2804)
- that calls a service
  - spec for job + move spec to service
  - minor refactoring
2019-05-16 13:46:50 -04:00
Anna Buianova
dd0fbf002b ActiveJob for updating notifications #1996 (#2839)
* Notifications::Update service

* Update notifications ActiveJob

* Raise an exception when wrong notifiable class passed to a job
2019-05-15 12:37:25 -04:00
cyrillefr
ecdbee64ab Move tag adjustment notification to Active Jobs (#2654) 2019-05-10 11:06:29 -04:00
Anna Buianova
065ef29e31 Added unique index to notifications #2124 (#2213)
* Added unique index to notifications #2124

* Fix migration + add index to schema.rb

* Shoulda matcher notification unique validation
2019-05-01 13:15:06 -04:00
rhymes
743316b528 Move send new badge achievement notification to ActiveJob (#2474) 2019-04-29 10:51:08 -04:00
cyrillefr
c3cb6d9b66 Move moderation notification to Active Jobs (#2550)
- send_moderation_notification in own job
    - that calls a service
    - specs for job + service
    - minor refactoring
2019-04-29 09:21:15 -04:00
cyrillefr
f3f8a51e35 Move Welcome Notification to Active Jobs (#2485)
- creation of welcome notification is in own service
  - which is called by an active job

Resolves: #1996
2019-04-22 13:49:18 -04:00
rhymes
d0441bb456 Enable Rails/TimeZone cop (#2334) [ci skip] 2019-04-09 15:38:28 -04:00
Anna Buianova
509c11e86f New comment notifications to Active Jobs #1996 (#2287)
* Send new comment notification service + specs

* Call new comment notification service from the model

* Return to non-bang notifications create

* An ActiveJob for the new comment notifications

* Call comments notification ActiveJob from Notification
2019-04-03 11:38:30 -04:00
Anna Buianova
75a977172c Fix notifications about the new child comments (#2233) 2019-03-29 12:51:10 -04:00
Anna Buianova
e1968e815b Extract new reaction notification to ActiveJob (#2122) 2019-03-25 13:54:21 -04:00