diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb index 5d20f8c2d656562ca4f12ed581b1d88df0da9451..08d70b7ac02ee71d7752a0821b409d6b8b22fe4a 100644 --- a/app/helpers/atom_builder_helper.rb +++ b/app/helpers/atom_builder_helper.rb @@ -191,6 +191,7 @@ module AtomBuilderHelper include_author xml, stream_entry.target else object_type xml, stream_entry.target.object_type + verb xml, stream_entry.target.verb title xml, stream_entry.target.title link_alternate xml, TagManager.instance.url_for(stream_entry.target) end diff --git a/app/models/block.rb b/app/models/block.rb index c2067c5b8ff738d5e441ff068cafc68259b006d9..d0662b685111e2eb4bbb91f38a2d074d32246e15 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -18,10 +18,6 @@ class Block < ApplicationRecord target_account end - def object_type - :person - end - def hidden? true end diff --git a/app/models/favourite.rb b/app/models/favourite.rb index cd8e2098c2f65c8fef4dbf1cb52f29d48329ed67..82f8c525863aed39e20cbb19c8d7dc6bccfba1fb 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -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}" end - delegate :object_type, to: :target - def thread status end diff --git a/app/models/follow.rb b/app/models/follow.rb index f83490caad3de05d1b1eb9e965e42513788cbd63..e25c2bc9f846f76d6cf202190dee294037b3a051 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -20,10 +20,6 @@ class Follow < ApplicationRecord target_account end - def object_type - :person - end - def title destroyed? ? "#{account.acct} is no longer following #{target_account.acct}" : "#{account.acct} started following #{target_account.acct}" end diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb index 989c2c2a23b345e28891fb43f41d3fcfa489a909..080c686e53ba9bbfe2705467696fcbae99f97221 100644 --- a/app/models/follow_request.rb +++ b/app/models/follow_request.rb @@ -13,7 +13,8 @@ class FollowRequest < ApplicationRecord validates :account_id, uniqueness: { scope: :target_account_id } def authorize! - @verb = :authorize + @verb = :authorize + @target = clone.freeze account.follow!(target_account) MergeWorker.perform_async(target_account.id, account.id) @@ -22,7 +23,9 @@ class FollowRequest < ApplicationRecord end def reject! - @verb = :reject + @verb = :reject + @target = clone.freeze + destroy! end @@ -31,11 +34,11 @@ class FollowRequest < ApplicationRecord end def target - target_account - end - - def object_type - :person + if destroyed? && @verb + @target + else + target_account + end end def hidden? diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb index e0b85be158915a851f231ba3226fdd037aba3125..bb68b1e141ff5b3cc5d462ce7561f637ef88cb86 100644 --- a/app/models/stream_entry.rb +++ b/app/models/stream_entry.rb @@ -6,10 +6,11 @@ class StreamEntry < ApplicationRecord belongs_to :account, inverse_of: :stream_entries belongs_to :activity, polymorphic: true - belongs_to :status, foreign_type: 'Status', 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 :block, foreign_type: 'Block', foreign_key: 'activity_id' + belongs_to :status, foreign_type: 'Status', 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 :block, foreign_type: 'Block', foreign_key: 'activity_id' + belongs_to :follow_request, foreign_type: 'FollowRequest', foreign_key: 'activity_id' validates :account, :activity, presence: true @@ -30,7 +31,7 @@ class StreamEntry < ApplicationRecord end 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 def target @@ -58,7 +59,7 @@ class StreamEntry < ApplicationRecord end def activity - !new_record? ? send(activity_type.downcase) : super + !new_record? ? send(activity_type.underscore) : super end private diff --git a/docs/Extensions.md b/docs/Extensions.md index b56b5b85c77ba2e0d6b5583817b6df0eaa02faf9..6a940eebcaa55098ce9f0997912147be63b8a054 100644 --- a/docs/Extensions.md +++ b/docs/Extensions.md @@ -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. -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: @@ -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/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 diff --git a/spec/models/favourite_spec.rb b/spec/models/favourite_spec.rb index 6cf3af4647fe51f438b74e94c151407ca0aa20e1..cc3d604d6035a5a35fc3bd83df0d54b470e204b4 100644 --- a/spec/models/favourite_spec.rb +++ b/spec/models/favourite_spec.rb @@ -26,13 +26,8 @@ RSpec.describe Favourite, type: :model do end describe '#object_type' do - it 'is a note when the target is a note' do - expect(subject.object_type).to be :note - 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 + it 'is an activity' do + expect(subject.object_type).to be :activity end end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index c9d02ab163138b7af893e40a653f7617a33a28cd..bc887b60d941d507738c0e29edd8f5a538359861 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -25,8 +25,8 @@ RSpec.describe Follow, type: :model do end describe '#object_type' do - it 'is a person' do - expect(subject.object_type).to be :person + it 'is an activity' do + expect(subject.object_type).to be :activity end end