Participation is not relayable anymore
only deliver to parent author
This commit is contained in:
parent
1c291260a2
commit
709ad6e909
4 changed files with 34 additions and 26 deletions
|
|
@ -2,7 +2,16 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
class Like < Federated::Relayable
|
||||
class Like < ActiveRecord::Base
|
||||
include Diaspora::Federated::Base
|
||||
include Diaspora::Fields::Guid
|
||||
include Diaspora::Fields::Author
|
||||
include Diaspora::Fields::Target
|
||||
|
||||
include Diaspora::Relayable
|
||||
|
||||
alias_attribute :parent, :target
|
||||
|
||||
class Generator < Federated::Generator
|
||||
def self.federated_class
|
||||
Like
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
class Participation < Federated::Relayable
|
||||
class Participation < ActiveRecord::Base
|
||||
include Diaspora::Federated::Base
|
||||
include Diaspora::Fields::Guid
|
||||
include Diaspora::Fields::Author
|
||||
include Diaspora::Fields::Target
|
||||
|
||||
class Generator < Federated::Generator
|
||||
def self.federated_class
|
||||
Participation
|
||||
Participation
|
||||
end
|
||||
|
||||
def relayable_options
|
||||
|
|
@ -17,6 +22,11 @@ class Participation < Federated::Relayable
|
|||
end
|
||||
end
|
||||
|
||||
# @return [Array<Person>]
|
||||
def subscribers
|
||||
[target.author]
|
||||
end
|
||||
|
||||
# NOTE API V1 to be extracted
|
||||
acts_as_api
|
||||
api_accessible :backbone do |t|
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
module Federated
|
||||
class Relayable < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
|
||||
include Diaspora::Federated::Base
|
||||
include Diaspora::Fields::Guid
|
||||
include Diaspora::Fields::Author
|
||||
include Diaspora::Fields::Target
|
||||
|
||||
include Diaspora::Relayable
|
||||
|
||||
alias_attribute :parent, :target
|
||||
end
|
||||
end
|
||||
|
|
@ -3,15 +3,18 @@ require "spec_helper"
|
|||
describe Participation, type: :model do
|
||||
let(:status) { bob.post(:status_message, text: "hello", to: bob.aspects.first.id) }
|
||||
|
||||
it_behaves_like "it is relayable" do
|
||||
let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) }
|
||||
let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) }
|
||||
let(:object_on_local_parent) { local_luke.participate!(local_parent) }
|
||||
let(:object_on_remote_parent) { local_luke.participate!(remote_parent) }
|
||||
let(:remote_object_on_local_parent) {
|
||||
FactoryGirl.create(:participation, target: local_parent, author: remote_raphael)
|
||||
}
|
||||
let(:relayable) { Participation::Generator.new(alice, status).build }
|
||||
describe "#subscribers" do
|
||||
it "returns the parent author on local parent" do
|
||||
local_parent = local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first)
|
||||
participation = local_luke.participate!(local_parent)
|
||||
expect(participation.subscribers).to match_array([local_luke.person])
|
||||
end
|
||||
|
||||
it "returns the parent author on remote parent" do
|
||||
remote_parent = FactoryGirl.create(:status_message, author: remote_raphael)
|
||||
participation = local_luke.participate!(remote_parent)
|
||||
expect(participation.subscribers).to match_array([remote_raphael])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#unparticipate" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue