Module: NewsmastMastodon::Overrides::NotificationV1ExtendedController
- Defined in:
- app/lib/newsmast_mastodon/overrides/notification_v1_extended_controller.rb
Constant Summary collapse
- DEFAULT_NOTIFICATIONS_LIMIT =
40
Instance Method Summary collapse
- #browserable_params ⇒ Object
- #filter_private_mentions(notifications) ⇒ Object
- #load_notifications ⇒ Object
- #pagination_params(core_params) ⇒ Object
Instance Method Details
#browserable_params ⇒ Object
29 30 31 |
# File 'app/lib/newsmast_mastodon/overrides/notification_v1_extended_controller.rb', line 29 def browserable_params params.permit(:account_id, :include_filtered, :exclude_private_mentions, types: [], exclude_types: []) end |
#filter_private_mentions(notifications) ⇒ Object
22 23 24 25 26 27 |
# File 'app/lib/newsmast_mastodon/overrides/notification_v1_extended_controller.rb', line 22 def filter_private_mentions(notifications) notifications.reject do |notification| notification.type == :mention && notification.target_status&.visibility == 'direct' end end |
#load_notifications ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/lib/newsmast_mastodon/overrides/notification_v1_extended_controller.rb', line 9 def load_notifications notifications = browserable_account_notifications.includes(from_account: [:account_stat, :user]).to_a_paginated_by_id( limit_param(DEFAULT_NOTIFICATIONS_LIMIT), params_slice(:max_id, :since_id, :min_id) ) notifications = filter_private_mentions(notifications) if truthy_param?(:exclude_private_mentions) Notification.preload_cache_collection_target_statuses(notifications) do |target_statuses| preload_collection(target_statuses, Status) end end |
#pagination_params(core_params) ⇒ Object
33 34 35 |
# File 'app/lib/newsmast_mastodon/overrides/notification_v1_extended_controller.rb', line 33 def pagination_params(core_params) params.slice(:limit, :account_id, :types, :exclude_types, :include_filtered, :exclude_private_mentions).permit(:limit, :account_id, :include_filtered, :exclude_private_mentions, types: [], exclude_types: []).merge(core_params) end |