forked from mirrors/catstodon
Follow call on locked account creates follow request instead
Reflect "requested" relationship in API and UI Reflect inability of private posts to be reblogged in the UI Disable Webfinger for locked accountsmain
parent
2d2154ba75
commit
b891a81008
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FollowRequest < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :target_account, class_name: 'Account'
|
||||
|
||||
validates :account, :target_account, presence: true
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
|
||||
def authorize!
|
||||
account.follow!(target_account)
|
||||
FeedManager.instance.merge_into_timeline(target_account, account)
|
||||
destroy!
|
||||
end
|
||||
|
||||
def reject!
|
||||
destroy!
|
||||
end
|
||||
end
|
@ -1,11 +1,11 @@
|
||||
object @account
|
||||
|
||||
attributes :id, :username, :acct, :display_name
|
||||
attributes :id, :username, :acct, :display_name, :locked
|
||||
|
||||
node(:note) { |account| Formatter.instance.simplified_format(account) }
|
||||
node(:url) { |account| TagManager.instance.url_for(account) }
|
||||
node(:avatar) { |account| full_asset_url(account.avatar.url( :original)) }
|
||||
node(:header) { |account| full_asset_url(account.header.url( :original)) }
|
||||
node(:avatar) { |account| full_asset_url(account.avatar.url(:original)) }
|
||||
node(:header) { |account| full_asset_url(account.header.url(:original)) }
|
||||
node(:followers_count) { |account| defined?(@followers_counts_map) ? (@followers_counts_map[account.id] || 0) : (account.try(:followers_count) || account.followers.count) }
|
||||
node(:following_count) { |account| defined?(@following_counts_map) ? (@following_counts_map[account.id] || 0) : (account.try(:following_count) || account.following.count) }
|
||||
node(:statuses_count) { |account| defined?(@statuses_counts_map) ? (@statuses_counts_map[account.id] || 0) : (account.try(:statuses_count) || account.statuses.count) }
|
||||
|
@ -0,0 +1,12 @@
|
||||
class CreateFollowRequests < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :follow_requests do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :target_account_id, null: false
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :follow_requests, [:account_id, :target_account_id], unique: true
|
||||
end
|
||||
end
|
@ -0,0 +1,3 @@
|
||||
Fabricator(:follow_request) do
|
||||
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FollowRequest, type: :model do
|
||||
describe '#authorize!'
|
||||
describe '#reject!'
|
||||
end
|
Loading…
Reference in New Issue