Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAccount domain blocks #2381
Conversation
| @@ -107,6 +107,10 @@ def blocking?(other_account) | ||
| blocking.include?(other_account) | ||
| end | ||
| + def domain_blocking?(other_account) | ||
| + AccountDomainBlock.where(account: self, domain: other_account.domain).exists? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mjankowski
Apr 24, 2017
Collaborator
Account could probably use a has_many for :account_domains_blocks, which this method could then use.
mjankowski
Apr 24, 2017
Collaborator
Account could probably use a has_many for :account_domains_blocks, which this method could then use.
| @@ -188,6 +188,8 @@ def permitted_for(target_account, account) | ||
| def filter_timeline(query, account) | ||
| blocked = Rails.cache.fetch("exclude_account_ids_for:#{account.id}") { Block.where(account: account).pluck(:target_account_id) + Block.where(target_account: account).pluck(:account_id) + Mute.where(account: account).pluck(:target_account_id) } | ||
| + domains = Rails.cache.fetch("exclude_domains_for:#{account_id}") { AccountDomainBlock.where(account: account).pluck(:domain) } |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mjankowski
Apr 24, 2017
Collaborator
Instead of a local variable here, how about a (Rails cached) method like Account#blocked_domains? which the next line could call directly
mjankowski
Apr 24, 2017
Collaborator
Instead of a local variable here, how about a (Rails cached) method like Account#blocked_domains? which the next line could call directly
| @@ -202,6 +210,14 @@ | ||
| t.datetime "image_updated_at" | ||
| t.datetime "created_at", null: false | ||
| t.datetime "updated_at", null: false | ||
| + t.integer "type", default: 0, null: false |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| @@ -0,0 +1,4 @@ | ||
| +Fabricator(:account_domain_block) do | ||
| + account_id 1 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
wxcafe
Apr 24, 2017
Contributor
Closing #501 since this is the same feature and that old PR is not up to date anymore (by a long shot)
|
Closing #501 since this is the same feature and that old PR is not up to date anymore (by a long shot) |
wxcafe
referenced this pull request
Apr 24, 2017
Closed
Better control over who's following me #2187
Gargron
added this to In progress
in v1.4 roadmap
May 11, 2017
Gargron
added some commits
May 7, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Gargron
May 14, 2017
Member
I can't imagine very well how the API for domain blocks should actually look.
GET /api/v1/domain_blocks - returns list of { id: domainBlockId, domain: blockedDomainString }
POST /api/v1/domain_blocks - creates domain block for "domain" param
How to unblock?! Use a DELETE route using the ID of the domain block? Use domains instead of IDs?
|
I can't imagine very well how the API for domain blocks should actually look.
How to unblock?! Use a DELETE route using the ID of the domain block? Use domains instead of IDs? |
Gargron
added some commits
May 18, 2017
Gargron
changed the title from
[WIP] Account domain blocks
to
Account domain blocks
May 18, 2017
beatrix-bitrot
requested changes
May 18, 2017
overall looks good, only very minor stuff
| - statuses = Status.where(id: ids).to_a | ||
| + statuses = Status.where(id: ids).includes(:account).to_a | ||
| + | ||
| + # FIXME: n+1 bonanza |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Gargron
May 18, 2017
Member
No it's been present since day 1, it's a fix for another day with less time pressure
Gargron
May 18, 2017
Member
No it's been present since day 1, it's a fix for another day with less time pressure
| + | ||
| + respond_to :json | ||
| + | ||
| + def show |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
beatrix-bitrot
May 18, 2017
Collaborator
curious why this is show and not index since it's giving a collection rather than an individual object
beatrix-bitrot
May 18, 2017
Collaborator
curious why this is show and not index since it's giving a collection rather than an individual object
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Gargron
May 18, 2017
Member
Because it's a "resource" route and not "resources" (so that we can send DELETE /api/v1/domain_blocks)
Gargron
May 18, 2017
Member
Because it's a "resource" route and not "resources" (so that we can send DELETE /api/v1/domain_blocks)
| @@ -150,7 +150,8 @@ | ||
| resources :favourites, only: [:index] | ||
| resources :reports, only: [:index, :create] | ||
| - resource :instance, only: [:show] | ||
| + resource :instance, only: [:show] | ||
| + resource :domain_blocks, only: [:show, :create, :destroy] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| +require 'rails_helper' | ||
| + | ||
| +RSpec.describe AccountDomainBlock, type: :model do | ||
| + pending "add some examples to (or delete) #{__FILE__}" |
Gargron commentedApr 24, 2017
•
edited
Edited 1 time
-
Gargron
edited May 18, 2017 (most recent)
Probably better done in another PR: