Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add from account to notifications api #10796

Merged
merged 6 commits into from
May 21, 2019
Merged

Add from account to notifications api #10796

merged 6 commits into from
May 21, 2019

Conversation

pwoolcoc
Copy link
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
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

app/models/notification.rb Outdated Show resolved Hide resolved
app/controllers/api/v1/notifications_controller.rb Outdated Show resolved Hide resolved
* use account id instead of user@domain
* name the param `account_id` instead of `from_account`
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
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
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
rtucker pushed a commit to vulpineclub/mastodon that referenced this pull request Jan 7, 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
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