remove roxml

This commit is contained in:
Benjamin Neff 2016-06-10 20:52:56 +02:00
parent fa5a35ed4a
commit 21fd9f23da
27 changed files with 13 additions and 197 deletions

View file

@ -136,7 +136,6 @@ gem "leaflet-rails", "0.7.7"
gem "nokogiri", "1.6.8"
gem "redcarpet", "3.3.4"
gem "twitter-text", "1.13.4"
gem "roxml", "3.1.6"
gem "ruby-oembed", "0.10.1"
gem "open_graph_reader", "0.6.1"

View file

@ -725,9 +725,6 @@ GEM
request_store (1.3.1)
responders (2.2.0)
railties (>= 4.2.0, < 5.1)
roxml (3.1.6)
activesupport (>= 2.3.0)
nokogiri (>= 1.3.3)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
@ -1015,7 +1012,6 @@ DEPENDENCIES
redcarpet (= 3.3.4)
remotipart (= 1.2.1)
responders (= 2.2.0)
roxml (= 3.1.6)
rspec-rails (= 3.4.2)
rubocop (= 0.40.0)
ruby-oembed (= 0.10.1)

View file

@ -10,10 +10,6 @@ class AccountDeletion < ActiveRecord::Base
belongs_to :person
after_commit :queue_delete_account, :on => :create
xml_name :account_deletion
xml_attr :diaspora_handle
def person=(person)
self[:diaspora_handle] = person.diaspora_handle
self[:person_id] = person.id

View file

@ -16,9 +16,6 @@ class Comment < ActiveRecord::Base
extract_tags_from :text
before_create :build_tags
xml_attr :text
xml_attr :diaspora_handle
belongs_to :commentable, :touch => true, :polymorphic => true
alias_attribute :post, :commentable
belongs_to :author, :class_name => 'Person'

View file

@ -2,12 +2,6 @@ class Conversation < ActiveRecord::Base
include Diaspora::Federated::Base
include Diaspora::Guid
xml_attr :subject
xml_attr :created_at
xml_attr :messages, :as => [Message]
xml_reader :diaspora_handle
xml_reader :participant_handles
has_many :conversation_visibilities, :dependent => :destroy
has_many :participants, :class_name => 'Person', :through => :conversation_visibilities, :source => :person
has_many :messages, -> { order('created_at ASC') }

View file

@ -23,8 +23,6 @@ class Like < Federated::Relayable
participation.unparticipate! if participation.present?
end
xml_attr :positive
# NOTE API V1 to be extracted
acts_as_api
api_accessible :backbone do |t|

View file

@ -5,9 +5,6 @@ class Location < ActiveRecord::Base
attr_accessor :coordinates
include Diaspora::Federated::Base
xml_attr :address
xml_attr :lat
xml_attr :lng
belongs_to :status_message

View file

@ -4,11 +4,6 @@ class Message < ActiveRecord::Base
include Diaspora::Guid
include Diaspora::Relayable
xml_attr :text
xml_attr :created_at
xml_reader :diaspora_handle
xml_reader :conversation_guid
belongs_to :author, :class_name => 'Person'
belongs_to :conversation, :touch => true

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class Person < ActiveRecord::Base
include ROXML
include Encryptor::Public
include Diaspora::Guid
@ -23,11 +22,6 @@ class Person < ActiveRecord::Base
}, :as => :avatar
end
xml_attr :diaspora_handle
xml_attr :url
xml_attr :profile, :as => Profile
xml_attr :exported_key
has_one :profile, dependent: :destroy
delegate :last_name, :image_url, :tag_string, :bio, :location,
:gender, :birthday, :formatted_birthday, :tags, :searchable,

View file

@ -37,15 +37,6 @@ class Photo < ActiveRecord::Base
mount_uploader :processed_image, ProcessedImage
mount_uploader :unprocessed_image, UnprocessedImage
xml_attr :remote_photo_path
xml_attr :remote_photo_name
xml_attr :text
xml_attr :status_message_guid
xml_attr :height
xml_attr :width
belongs_to :status_message, :foreign_key => :status_message_guid, :primary_key => :guid
validates_associated :status_message
delegate :author_name, to: :status_message, prefix: true

View file

@ -7,9 +7,6 @@ class Poll < ActiveRecord::Base
has_many :poll_participations
has_one :author, through: :status_message
xml_attr :question
xml_attr :poll_answers, :as => [PollAnswer]
#forward some requests to status message, because a poll is just attached to a status message and is not sharable itself
delegate :author_id, :diaspora_handle, :public?, :subscribers, to: :status_message

View file

@ -1,15 +1,11 @@
class PollAnswer < ActiveRecord::Base
include Diaspora::Federated::Base
include Diaspora::Guid
belongs_to :poll
has_many :poll_participations
xml_attr :answer
validates :answer, presence: true
self.include_root_in_json = false
end

View file

@ -1,15 +1,13 @@
class PollParticipation < ActiveRecord::Base
include Diaspora::Federated::Base
include Diaspora::Guid
include Diaspora::Relayable
belongs_to :poll
belongs_to :poll_answer, counter_cache: :vote_count
belongs_to :author, :class_name => 'Person', :foreign_key => :author_id
xml_attr :diaspora_handle
xml_attr :poll_answer_guid
xml_convention :underscore
validate :not_already_participated
def parent_class

View file

@ -18,8 +18,6 @@ class Post < ActiveRecord::Base
attr_accessor :user_like
xml_attr :provider_display_name
has_many :reports, as: :item
has_many :mentions, dependent: :destroy

View file

@ -13,20 +13,6 @@ class Profile < ActiveRecord::Base
extract_tags_from :tag_string
validates :tag_list, :length => { :maximum => 5 }
xml_attr :diaspora_handle
xml_attr :first_name
xml_attr :last_name
xml_attr :image_url
xml_attr :image_url_small
xml_attr :image_url_medium
xml_attr :birthday
xml_attr :gender
xml_attr :bio
xml_attr :location
xml_attr :searchable
xml_attr :nsfw
xml_attr :tag_string
before_save :strip_names
after_validation :strip_names

View file

@ -9,9 +9,6 @@ class Reshare < Post
validates_uniqueness_of :root_guid, :scope => :author_id
delegate :author, to: :root, prefix: true
xml_attr :root_diaspora_id
xml_attr :root_guid
before_validation do
self.public = true
end

View file

@ -15,12 +15,6 @@ class StatusMessage < Post
# don't allow creation of empty status messages
validate :presence_of_content, on: :create, if: proc {|sm| sm.author && sm.author.local? }
xml_name :status_message
xml_attr :raw_message
xml_attr :photos, :as => [Photo]
xml_attr :location, :as => Location
xml_attr :poll, :as => Poll
has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid
has_one :location

View file

@ -12,5 +12,4 @@ module Diaspora
require "diaspora/markdownify"
require "diaspora/mentionable"
require "diaspora/message_renderer"
require "diaspora/parser"
end

View file

@ -33,13 +33,7 @@ module Diaspora
# @return [Array<String>] The ROXML attrs other than author_signature and parent_author_signature.
def signable_accessors
accessors = self.class.roxml_attrs.collect do |definition|
definition.accessor
end
['author_signature', 'parent_author_signature'].each do |acc|
accessors.delete acc
end
accessors
[]
end
# @return [String] Defaults to the ROXML attrs which are not signatures.

View file

@ -2,46 +2,16 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#the base level federation contract, which right now means that the object
#can be serialized and deserialized from xml, and respond to methods
#in the federation flow
# including this module lets you federate an object at the most basic of level
module Diaspora
module Federated
module Base
include Diaspora::Logging
def self.included(model)
model.instance_eval do
include ROXML
include Diaspora::Federated::Base::InstanceMethods
end
end
module InstanceMethods
def to_diaspora_xml
xml = to_xml
::Logging::Logger["XMLLogger"].debug "to_xml: #{xml}"
<<-XML
<XML>
<post>#{xml}</post>
</XML>
XML
end
def x(input)
input.to_s.to_xs
end
# @abstract
# @note this must return [Array<Person>]
# @return [Array<Person>]
def subscribers
raise 'You must override subscribers in order to enable federation on this model'
end
raise "You must override subscribers in order to enable federation on this model"
end
end
end

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class RelayableRetraction < SignedRetraction
xml_name :relayable_retraction
xml_attr :parent_author_signature
attr_accessor :parent_author_signature
delegate :parent, :parent_author, to: :target, allow_nil: true

View file

@ -1,12 +1,10 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class Retraction
include Diaspora::Federated::Base
xml_accessor :post_guid
xml_accessor :diaspora_handle
xml_accessor :type
include Diaspora::Logging
attr_reader :subscribers, :data

View file

@ -7,12 +7,6 @@ class SignedRetraction
include Diaspora::Encryptable
xml_name :signed_retraction
xml_attr :target_guid
xml_attr :target_type
xml_attr :sender_handle
xml_attr :target_author_signature
attr_accessor :target_guid,
:target_type,
:target_author_signature,
@ -27,13 +21,6 @@ class SignedRetraction
end
end
def signable_accessors
accessors = self.class.roxml_attrs.collect do |definition|
definition.accessor
end
accessors - ['target_author_signature', 'sender_handle']
end
def sender_handle= new_sender_handle
@sender = Person.where(:diaspora_handle => new_sender_handle).first
end

View file

@ -1,13 +1,9 @@
#implicitly requires roxml
module Diaspora::Guid
# Creates a before_create callback which calls #set_guid and makes the guid serialize in to_xml
# Creates a before_create callback which calls #set_guid
def self.included(model)
model.class_eval do
after_initialize :set_guid
xml_attr :guid
validates :guid, :uniqueness => true
end
end

View file

@ -1,22 +0,0 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Diaspora
module Parser
def self.from_xml(xml)
doc = Nokogiri::XML(xml) {|cfg| cfg.noblanks }
return unless body = doc.xpath("/XML/post").children.first
class_name = body.name.gsub("-", "/")
::Logging::Logger["XMLLogger"].debug "from_xml: #{body}"
begin
class_name.camelize.constantize.from_xml body.to_s
rescue NameError => e
# A pods is trying to federate an object we don't recognize.
# i.e. their codebase is different from ours.
::Logging::Logger[self].warn("Error while parsing the xml: #{e.message}")
nil
end
end
end
end

View file

@ -10,11 +10,6 @@ module Diaspora
model.class_eval do
attr_writer :parent_author_signature
#these fields must be in the schema for a relayable model
xml_attr :parent_guid
xml_attr :parent_author_signature
xml_attr :author_signature
validates_associated :parent
validates :author, :presence => true
validate :author_is_not_ignored
@ -102,17 +97,5 @@ module Diaspora
def parent= parent
raise NotImplementedError.new('you must override parent= in order to enable relayable on this model')
end
# ROXML hook ensuring our own hooks are called
def after_parse
if @parent_guid
self.parent ||= fetch_parent(@parent_guid)
end
end
# Childs should override this to support fetching a missing parent
# @param guid the parents guid
def fetch_parent guid
end
end
end

View file

@ -2,16 +2,11 @@ module Federated
class Relayable < ActiveRecord::Base
self.abstract_class = true
#crazy ordering issues - DEATH TO ROXML
include Diaspora::Federated::Base
include Diaspora::Guid
#seriously, don't try to move this shit around until you have killed ROXML
xml_attr :target_type
include Diaspora::Relayable
xml_attr :diaspora_handle
belongs_to :target, :polymorphic => true
belongs_to :author, :class_name => 'Person'
#end crazy ordering issues
@ -38,9 +33,5 @@ module Federated
def parent= parent
self.target = parent
end
def fetch_parent guid
raise Diaspora::PostNotFetchable
end
end
end