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

Lists #5703

Merged
merged 9 commits into from
Nov 17, 2017
Merged

Lists #5703

merged 9 commits into from
Nov 17, 2017

Conversation

Gargron
Copy link
Member

@Gargron 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

@Gargron Gargron added api REST API, Streaming API, Web Push API work in progress Not to be merged, currently being worked on labels Nov 15, 2017
@Gargron Gargron force-pushed the feature-lists branch 2 times, most recently from 92d2690 to 305ee4c Compare November 16, 2017 17:08
@Gargron Gargron force-pushed the feature-lists branch 2 times, most recently from f953418 to 983a648 Compare November 16, 2017 17:50
@Gargron Gargron removed the work in progress Not to be merged, currently being worked on label Nov 16, 2017
Copy link
Member

@nightpool nightpool left a comment

Choose a reason for hiding this comment

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

needs an update to remove_status_service_spec for Feed -> HomeFeed.

needs a corresponding /documentation PR

render_views

let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow') }
Copy link
Member

Choose a reason for hiding this comment

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

wrong scopes

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

Choose a reason for hiding this comment

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

No from_database for lists?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question from me.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine punting on this for now.

@@ -0,0 +1,13 @@
# frozen_string_literal: true

class ListPolicy < ApplicationPolicy
Copy link
Member

Choose a reason for hiding this comment

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

Is this ever used by Doorkeeper? I couldn't find any indication that doorkeeper checked pundit policies....

@@ -27,33 +27,41 @@ def filter?(timeline_type, status, receiver_id)
end

def push(timeline_type, account, status)
Copy link
Member

@nightpool nightpool Nov 16, 2017

Choose a reason for hiding this comment

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

Considering that we only ever use push(:home) (as far as I can tell....) and we're adding a push_to_list anyway, we should probably make a push_to_home method, and then either get rid of push or make it private and get rid of any code duplication between it and push_to_list

(same with unpush)

@nightpool nightpool requested review from nightpool and removed request for nightpool November 16, 2017 20:13
@cwebber
Copy link

cwebber commented Nov 16, 2017

Any thought of exposing these as AS2 Collections?

- Creating and modifying lists merely requires "write" scope
- Fetching information about lists merely requires "read" scope
@nightpool
Copy link
Member

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

Copy link
Contributor

@aschmitz aschmitz left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

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.)

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh? No, hashtags timelines are not stored in redis

Copy link
Member

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

require 'rails_helper'

RSpec.describe ListAccount, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd either add tests or drop this (and list_spec.rb).

Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Huh? Why would we go back to integer?

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

see the conversation on #5461

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Same question from me.

@mastodon mastodon deleted a comment from ClearlyClaire Nov 17, 2017
@mastodon mastodon deleted a comment from ClearlyClaire Nov 17, 2017
@mastodon mastodon deleted a comment from ClearlyClaire Nov 17, 2017
@nightpool
Copy link
Member

Still needs remove_status_service_spec update.

@Gargron Gargron merged commit 24cafd7 into master Nov 17, 2017
@Gargron Gargron deleted the feature-lists branch November 17, 2017 23:51
hannahwhy added a commit to glitch-soc/mastodon that referenced this pull request Nov 17, 2017
@Gargron Gargron mentioned this pull request Nov 27, 2017
10 tasks
cobodo pushed a commit to cobodo/mastodon that referenced this pull request Dec 6, 2017
* 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
Copy link

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

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
Labels
api REST API, Streaming API, Web Push API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants