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
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# 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
|
class Generator < Federated::Generator
|
||||||
def self.federated_class
|
def self.federated_class
|
||||||
Like
|
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
|
class Generator < Federated::Generator
|
||||||
def self.federated_class
|
def self.federated_class
|
||||||
Participation
|
Participation
|
||||||
end
|
end
|
||||||
|
|
||||||
def relayable_options
|
def relayable_options
|
||||||
|
|
@ -17,6 +22,11 @@ class Participation < Federated::Relayable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Array<Person>]
|
||||||
|
def subscribers
|
||||||
|
[target.author]
|
||||||
|
end
|
||||||
|
|
||||||
# NOTE API V1 to be extracted
|
# NOTE API V1 to be extracted
|
||||||
acts_as_api
|
acts_as_api
|
||||||
api_accessible :backbone do |t|
|
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
|
describe Participation, type: :model do
|
||||||
let(:status) { bob.post(:status_message, text: "hello", to: bob.aspects.first.id) }
|
let(:status) { bob.post(:status_message, text: "hello", to: bob.aspects.first.id) }
|
||||||
|
|
||||||
it_behaves_like "it is relayable" do
|
describe "#subscribers" do
|
||||||
let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) }
|
it "returns the parent author on local parent" do
|
||||||
let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) }
|
local_parent = local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first)
|
||||||
let(:object_on_local_parent) { local_luke.participate!(local_parent) }
|
participation = local_luke.participate!(local_parent)
|
||||||
let(:object_on_remote_parent) { local_luke.participate!(remote_parent) }
|
expect(participation.subscribers).to match_array([local_luke.person])
|
||||||
let(:remote_object_on_local_parent) {
|
end
|
||||||
FactoryGirl.create(:participation, target: local_parent, author: remote_raphael)
|
|
||||||
}
|
it "returns the parent author on remote parent" do
|
||||||
let(:relayable) { Participation::Generator.new(alice, status).build }
|
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
|
end
|
||||||
|
|
||||||
describe "#unparticipate" do
|
describe "#unparticipate" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue