gearheads
/
mastodon
Archived
2
0
Fork 0

Fix semantics of follow requests another slaps

gh/stable
Eugen Rochko 2017-02-11 17:09:36 +01:00
parent 0b95eb3612
commit 50660d54e8
9 changed files with 24 additions and 34 deletions

View File

@ -191,6 +191,7 @@ module AtomBuilderHelper
include_author xml, stream_entry.target include_author xml, stream_entry.target
else else
object_type xml, stream_entry.target.object_type object_type xml, stream_entry.target.object_type
verb xml, stream_entry.target.verb
title xml, stream_entry.target.title title xml, stream_entry.target.title
link_alternate xml, TagManager.instance.url_for(stream_entry.target) link_alternate xml, TagManager.instance.url_for(stream_entry.target)
end end

View File

@ -18,10 +18,6 @@ class Block < ApplicationRecord
target_account target_account
end end
def object_type
:person
end
def hidden? def hidden?
true true
end end

View File

@ -19,8 +19,6 @@ class Favourite < ApplicationRecord
destroyed? ? "#{account.acct} no longer favourites a status by #{status.account.acct}" : "#{account.acct} favourited a status by #{status.account.acct}" destroyed? ? "#{account.acct} no longer favourites a status by #{status.account.acct}" : "#{account.acct} favourited a status by #{status.account.acct}"
end end
delegate :object_type, to: :target
def thread def thread
status status
end end

View File

@ -20,10 +20,6 @@ class Follow < ApplicationRecord
target_account target_account
end end
def object_type
:person
end
def title def title
destroyed? ? "#{account.acct} is no longer following #{target_account.acct}" : "#{account.acct} started following #{target_account.acct}" destroyed? ? "#{account.acct} is no longer following #{target_account.acct}" : "#{account.acct} started following #{target_account.acct}"
end end

View File

@ -14,6 +14,7 @@ class FollowRequest < ApplicationRecord
def authorize! def authorize!
@verb = :authorize @verb = :authorize
@target = clone.freeze
account.follow!(target_account) account.follow!(target_account)
MergeWorker.perform_async(target_account.id, account.id) MergeWorker.perform_async(target_account.id, account.id)
@ -23,6 +24,8 @@ class FollowRequest < ApplicationRecord
def reject! def reject!
@verb = :reject @verb = :reject
@target = clone.freeze
destroy! destroy!
end end
@ -31,11 +34,11 @@ class FollowRequest < ApplicationRecord
end end
def target def target
if destroyed? && @verb
@target
else
target_account target_account
end end
def object_type
:person
end end
def hidden? def hidden?

View File

@ -10,6 +10,7 @@ class StreamEntry < ApplicationRecord
belongs_to :follow, foreign_type: 'Follow', foreign_key: 'activity_id' belongs_to :follow, foreign_type: 'Follow', foreign_key: 'activity_id'
belongs_to :favourite, foreign_type: 'Favourite', foreign_key: 'activity_id' belongs_to :favourite, foreign_type: 'Favourite', foreign_key: 'activity_id'
belongs_to :block, foreign_type: 'Block', foreign_key: 'activity_id' belongs_to :block, foreign_type: 'Block', foreign_key: 'activity_id'
belongs_to :follow_request, foreign_type: 'FollowRequest', foreign_key: 'activity_id'
validates :account, :activity, presence: true validates :account, :activity, presence: true
@ -30,7 +31,7 @@ class StreamEntry < ApplicationRecord
end end
def targeted? def targeted?
[:follow, :request_friend, :authorize, :unfollow, :block, :unblock, :share, :favorite].include? verb [:follow, :request_friend, :authorize, :reject, :unfollow, :block, :unblock, :share, :favorite].include? verb
end end
def target def target
@ -58,7 +59,7 @@ class StreamEntry < ApplicationRecord
end end
def activity def activity
!new_record? ? send(activity_type.downcase) : super !new_record? ? send(activity_type.underscore) : super
end end
private private

View File

@ -23,7 +23,7 @@ Accounts and statuses have an access "scope":
Accounts can be "private" or "public". The former requires a follow request to be approved before a follow relationship can be established, the latter can be followed directly. Accounts can be "private" or "public". The former requires a follow request to be approved before a follow relationship can be established, the latter can be followed directly.
Statuses can be "private", "unlisted" or "public". Private must only be shown to the followers of the account, public can be displayed publicly. Unlisted statuses may be displayed publicly but preferably outside of any spotlights e.g. "whole known network" or "public" timelines. Statuses can be "private", "unlisted" or "public". Private must only be shown to the followers of the account or people mentioned in the status; public can be displayed publicly. Unlisted statuses may be displayed publicly but preferably outside of any spotlights e.g. "whole known network" or "public" timelines.
Namespace of the scope element is `http://mastodon.social/schema/1.0`. Example: Namespace of the scope element is `http://mastodon.social/schema/1.0`. Example:
@ -47,7 +47,7 @@ Mastodon uses the following Salmon slaps to signal a follow request, a follow re
- `http://activitystrea.ms/schema/1.0/authorize` - `http://activitystrea.ms/schema/1.0/authorize`
- `http://activitystrea.ms/schema/1.0/reject` - `http://activitystrea.ms/schema/1.0/reject`
The activity object of the slaps is the account in question. Request-friend slap is sent to that account, when the end-user of that account decides, the authorize/reject decision slap is sent back to the requester. The activity object of the request-friend slap is the account in question. The activity object of the authorize and reject slaps is the original request-friend activity. Request-friend slap is sent to the locked account, when the end-user of that account decides, the authorize/reject decision slap is sent back to the requester.
#### PuSH amendment #### PuSH amendment

View File

@ -26,13 +26,8 @@ RSpec.describe Favourite, type: :model do
end end
describe '#object_type' do describe '#object_type' do
it 'is a note when the target is a note' do it 'is an activity' do
expect(subject.object_type).to be :note expect(subject.object_type).to be :activity
end
it 'is a comment when the target is a comment' do
status.in_reply_to_id = 2
expect(subject.object_type).to be :comment
end end
end end

View File

@ -25,8 +25,8 @@ RSpec.describe Follow, type: :model do
end end
describe '#object_type' do describe '#object_type' do
it 'is a person' do it 'is an activity' do
expect(subject.object_type).to be :person expect(subject.object_type).to be :activity
end end
end end