Skip to content

Add from account to notifications api#10796

Merged
Gargron merged 6 commits intomastodon:masterfrom
pwoolcoc:add-from-account-to-notifications-api
May 21, 2019
Merged

Add from account to notifications api#10796
Gargron merged 6 commits intomastodon:masterfrom
pwoolcoc:add-from-account-to-notifications-api

Conversation

@pwoolcoc
Copy link
Copy Markdown
Contributor

This adds the ability to filter notifications by the account they originated from. Currently there is no UI for this, it only adds the ability to the API.

Copy link
Copy Markdown
Member

@Gargron Gargron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, just need some details changed

Comment thread app/models/notification.rb Outdated
Comment thread app/controllers/api/v1/notifications_controller.rb Outdated
* use account id instead of user@domain
* name the param `account_id` instead of `from_account`
Comment thread app/models/notification.rb Outdated
scope :browserable, ->(exclude_types = [], account_id = nil) {
types = TYPE_CLASS_MAP.values - activity_types_from_types(exclude_types + [:follow_request])
where(activity_type: types)
return where(activity_type: types) if account_id.nil?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lambda, not a method, so the return keyword acts differently here. I suggest just an if/else block. Or you can change the scope to a class-level method:

class << self
  def browserable(exclude_types = [], account_id = nil)
    types = TYPE_CLASS_MAP.values - activity_types_from_types(exclude_types + [:follow_request])
    return where(activity_type: types) if account_id.nil?
    where(activity_type: types, from_account_id: account_id)
  end
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, though I thought return acted differently in procs not lambdas

@Gargron Gargron merged commit 0c933c1 into mastodon:master May 21, 2019
SnDer pushed a commit to quey-org/docs that referenced this pull request Jul 3, 2019
This PR is dependent on another PR getting merged: mastodon/mastodon#10796 . If that PR is not accepted, this can also be closed
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* Add `from_account` to notifications API

this adds the ability to filter notifications by the account they
originated from

* passing a non-existent user should cause none to be returned

* Fix codeclimate warnings

* fix more codeclimate warnings

* make requested changes:

* use account id instead of user@domain
* name the param `account_id` instead of `from_account`

* Don't use `return` in a lambda
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* Add `from_account` to notifications API

this adds the ability to filter notifications by the account they
originated from

* passing a non-existent user should cause none to be returned

* Fix codeclimate warnings

* fix more codeclimate warnings

* make requested changes:

* use account id instead of user@domain
* name the param `account_id` instead of `from_account`

* Don't use `return` in a lambda
Gargron pushed a commit to mastodon/documentation that referenced this pull request Jan 5, 2020
This PR is dependent on another PR getting merged: mastodon/mastodon#10796 . If that PR is not accepted, this can also be closed
messenjahofchrist pushed a commit to Origin-Creative/mastodon that referenced this pull request Jul 30, 2021
* Add `from_account` to notifications API

this adds the ability to filter notifications by the account they
originated from

* passing a non-existent user should cause none to be returned

* Fix codeclimate warnings

* fix more codeclimate warnings

* make requested changes:

* use account id instead of user@domain
* name the param `account_id` instead of `from_account`

* Don't use `return` in a lambda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants