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

Lists #5703

Merged
merged 9 commits into from Nov 17, 2017

Conversation

Projects
None yet
7 participants
@Gargron
Member

Gargron commented Nov 15, 2017

Fix #134

  • Database structure for storing lists
  • Adjust FeedManager to handle list timelines
  • Add lists to streaming API
  • API for managing lists

Web UI implementation should come in a different PR.


New APIs:

  • GET /api/v1/timelines/list/:id Timeline of a list
  • GET /api/v1/lists All your lists
  • POST /api/v1/lists Create a new list (allowed param: title)
  • GET/PUT/DELETE /api/v1/lists/:id
  • GET /api/v1/lists/:id/accounts All accounts in the list
  • POST/DELETE /api/v1/lists/:id/accounts Add or remove accounts to/from the list (array param: account_ids)

New streaming API:

  • /api/v1/streaming/list?list=:id Subscribe to list timeline

Other information:

  • Lists are private to their creator
  • Only people you follow can be added to your lists
  • If a follow stops existing, their list membership also stops existing
@nightpool

needs an update to remove_status_service_spec for Feed -> HomeFeed.

needs a corresponding /documentation PR

Show outdated Hide outdated spec/controllers/api/v1/lists/accounts_controller_spec.rb Outdated
def initialize(list)
@type = :list
@id = list.id
end

This comment has been minimized.

@nightpool

nightpool Nov 16, 2017

Collaborator

No from_database for lists?

@nightpool

nightpool Nov 16, 2017

Collaborator

No from_database for lists?

This comment has been minimized.

@ThibG

ThibG Nov 17, 2017

Collaborator

Same question from me.

@ThibG

ThibG Nov 17, 2017

Collaborator

Same question from me.

This comment has been minimized.

@nightpool

nightpool Nov 17, 2017

Collaborator

I'm fine punting on this for now.

@nightpool

nightpool Nov 17, 2017

Collaborator

I'm fine punting on this for now.

Show outdated Hide outdated app/policies/list_policy.rb Outdated
Show outdated Hide outdated app/lib/feed_manager.rb Outdated

@nightpool nightpool requested review from nightpool and removed request for nightpool Nov 16, 2017

@cwebber

This comment has been minimized.

Show comment
Hide comment
@cwebber

cwebber Nov 16, 2017

Any thought of exposing these as AS2 Collections?

cwebber commented Nov 16, 2017

Any thought of exposing these as AS2 Collections?

Adjust scopes for new APIs
- Creating and modifying lists merely requires "write" scope
- Fetching information about lists merely requires "read" scope
@nightpool

This comment has been minimized.

Show comment
Hide comment
@nightpool

nightpool Nov 17, 2017

Collaborator

@cwebber right now lists are entirely private and no one else can see them. If we add other functionality then we might consider that

Collaborator

nightpool commented Nov 17, 2017

@cwebber right now lists are entirely private and no one else can see them. If we add other functionality then we might consider that

@aschmitz

This looks reasonably good overall. The bulk endpoint is apparently new, so it would be good to make sure it's appropriately documented. A few minor comments for possible changes, but I don't know that any of them are really necessary.

@@ -30,15 +31,25 @@ def call(status)
def deliver_to_self(status)
Rails.logger.debug "Delivering status #{status.id} to author"
FeedManager.instance.push(:home, status.account, status)
FeedManager.instance.push_to_home(status.account, status)

This comment has been minimized.

@aschmitz

aschmitz Nov 17, 2017

Contributor

What if you're in one of your own lists?

@aschmitz

aschmitz Nov 17, 2017

Contributor

What if you're in one of your own lists?

This comment has been minimized.

@Gargron

Gargron Nov 17, 2017

Member

You can't follow yourself so you can't add yourself to a list.

@Gargron

Gargron Nov 17, 2017

Member

You can't follow yourself so you can't add yourself to a list.

PushUpdateWorker.perform_async(account.id, status.id) if push_update_required?(timeline_type, account.id)
def push_to_home(account, status)

This comment has been minimized.

@aschmitz

aschmitz Nov 17, 2017

Contributor

Is there a good reason to call push_to_home and push_to_list separately outside of FeedManager? Should we just expose push_to_user and let FeedManager sort out lists? (This seems less efficient, but perhaps cleaner. I can see arguments on either side.)

@aschmitz

aschmitz Nov 17, 2017

Contributor

Is there a good reason to call push_to_home and push_to_list separately outside of FeedManager? Should we just expose push_to_user and let FeedManager sort out lists? (This seems less efficient, but perhaps cleaner. I can see arguments on either side.)

This comment has been minimized.

@Gargron

Gargron Nov 17, 2017

Member

As I started writing the code, the push behaviour was different enough that I had to create a separate push_to_list method. But as I refactored, they turned out pretty similar after all. However, I am absolutely OK with keeping them separate for now. As they say, the DRY principle kicks in for n >= 3

@Gargron

Gargron Nov 17, 2017

Member

As I started writing the code, the push behaviour was different enough that I had to create a separate push_to_list method. But as I refactored, they turned out pretty similar after all. However, I am absolutely OK with keeping them separate for now. As they say, the DRY principle kicks in for n >= 3

This comment has been minimized.

@nightpool

nightpool Nov 17, 2017

Collaborator

My thought was that it mirrors push_to_hashtag, which isn't in feed_manager but does need to happen

@nightpool

nightpool Nov 17, 2017

Collaborator

My thought was that it mirrors push_to_hashtag, which isn't in feed_manager but does need to happen

This comment has been minimized.

@Gargron

Gargron Nov 17, 2017

Member

Huh? No, hashtags timelines are not stored in redis

@Gargron

Gargron Nov 17, 2017

Member

Huh? No, hashtags timelines are not stored in redis

This comment has been minimized.

@nightpool

nightpool Nov 17, 2017

Collaborator

Yes, but it mirrors the necessity of calling all of those different functions (see the calling site)

@nightpool

nightpool Nov 17, 2017

Collaborator

Yes, but it mirrors the necessity of calling all of those different functions (see the calling site)

allow(controller).to receive(:doorkeeper_token) { token }
end
context 'with a user context' do

This comment has been minimized.

@aschmitz

aschmitz Nov 17, 2017

Contributor

It may be worth testing with a different user's context as well, to ensure the list isn't accidentally exposed.

@aschmitz

aschmitz Nov 17, 2017

Contributor

It may be worth testing with a different user's context as well, to ensure the list isn't accidentally exposed.

Show outdated Hide outdated spec/models/list_account_spec.rb Outdated

@ThibG ThibG self-requested a review Nov 17, 2017

@ThibG

I'm confused about the bigint VS integer things and I wonder about not having a method to load lists from database when Redis cache doesn't exist

@@ -3,7 +3,7 @@
#
# Table name: accounts
#
# id :bigint not null, primary key
# id :integer not null, primary key
# username :string default(""), not null

This comment has been minimized.

@ThibG

ThibG Nov 17, 2017

Collaborator

Huh? Why would we go back to integer?

@ThibG

ThibG Nov 17, 2017

Collaborator

Huh? Why would we go back to integer?

This comment has been minimized.

@nightpool

nightpool Nov 17, 2017

Collaborator

These model annotations are auto-generated. I've deleted the rest of your comments because they're not a concern.

@nightpool

nightpool Nov 17, 2017

Collaborator

These model annotations are auto-generated. I've deleted the rest of your comments because they're not a concern.

This comment has been minimized.

@ThibG

ThibG Nov 17, 2017

Collaborator

Right. Still, noisy for no reason, and I don't understand why they would be generated that way? db/schema.rb seems fine, though.

@ThibG

ThibG Nov 17, 2017

Collaborator

Right. Still, noisy for no reason, and I don't understand why they would be generated that way? db/schema.rb seems fine, though.

This comment has been minimized.

@nightpool

nightpool Nov 17, 2017

Collaborator

see the conversation on #5461

@nightpool

nightpool Nov 17, 2017

Collaborator

see the conversation on #5461

This comment has been minimized.

@Gargron

Gargron Nov 17, 2017

Member

Every db:migrate is gonna reset these to this. So I'd rather have them wrong than deal with noise in every PR. I shouldn't have merged #5461 but I did not realize annotate would not pick up the correct types, thought something just got forgotten because of the unusual way we performed the snowflake migrations.

@Gargron

Gargron Nov 17, 2017

Member

Every db:migrate is gonna reset these to this. So I'd rather have them wrong than deal with noise in every PR. I shouldn't have merged #5461 but I did not realize annotate would not pick up the correct types, thought something just got forgotten because of the unusual way we performed the snowflake migrations.

def initialize(list)
@type = :list
@id = list.id
end

This comment has been minimized.

@ThibG

ThibG Nov 17, 2017

Collaborator

Same question from me.

@ThibG

ThibG Nov 17, 2017

Collaborator

Same question from me.

@tootsuite tootsuite deleted a comment from ThibG Nov 17, 2017

@tootsuite tootsuite deleted a comment from ThibG Nov 17, 2017

@tootsuite tootsuite deleted a comment from ThibG Nov 17, 2017

@nightpool

This comment has been minimized.

Show comment
Hide comment
@nightpool

nightpool Nov 17, 2017

Collaborator

Still needs remove_status_service_spec update.

Collaborator

nightpool commented Nov 17, 2017

Still needs remove_status_service_spec update.

@Gargron Gargron merged commit 24cafd7 into master Nov 17, 2017

3 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@Gargron Gargron deleted the feature-lists branch Nov 17, 2017

yipdw added a commit to glitch-soc/mastodon that referenced this pull request Nov 17, 2017

@rinsuki rinsuki referenced this pull request Nov 22, 2017

Merged

Support Lists #72

@Gargron Gargron referenced this pull request Nov 27, 2017

Merged

Bump version to 2.1.0rc1 #5834

10 of 10 tasks complete

cobodo pushed a commit to cobodo/mastodon that referenced this pull request Dec 6, 2017

Lists (tootsuite#5703)
* Add structure for lists

* Add list timeline streaming API

* Add list APIs, bind list-account relation to follow relation

* Add API for adding/removing accounts from lists

* Add pagination to lists API

* Add pagination to list accounts API

* Adjust scopes for new APIs

- Creating and modifying lists merely requires "write" scope
- Fetching information about lists merely requires "read" scope

* Add test for wrong user context on list timeline

* Clean up tests
@aquariusdev

This comment has been minimized.

Show comment
Hide comment
@aquariusdev

aquariusdev Apr 18, 2018

Can you add the ability to add/remove users to/from lists on their profile?

Mockup 1, borrowed a bit from Diaspora:
mastodon aspects dropdown mockup

Mockup 2, using existing menus on Mastodon:
mastodon add to remove from lists thru profile

Mockup 3, using Twitter's Add to/Remove from Lists pop-up:
twitter multi-select

aquariusdev commented Apr 18, 2018

Can you add the ability to add/remove users to/from lists on their profile?

Mockup 1, borrowed a bit from Diaspora:
mastodon aspects dropdown mockup

Mockup 2, using existing menus on Mastodon:
mastodon add to remove from lists thru profile

Mockup 3, using Twitter's Add to/Remove from Lists pop-up:
twitter multi-select

@Cassolotl

This comment has been minimized.

Show comment
Hide comment
@Cassolotl

Cassolotl Apr 18, 2018

@aquariusdev Since this is a pull request that was merged a while ago, it's probably best to create a new issue for your feature request!

Cassolotl commented Apr 18, 2018

@aquariusdev Since this is a pull request that was merged a while ago, it's probably best to create a new issue for your feature request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment