0
0
Fork 0

Remove Atom feeds and old URLs in the form of GET /:username/updates/:id (#11247)

This commit is contained in:
Eugen Rochko 2019-07-07 16:16:51 +02:00 committed by GitHub
parent 406b46395d
commit b851456139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 130 additions and 2791 deletions

View file

@ -11,7 +11,6 @@ module AccountAssociations
has_many :identity_proofs, class_name: 'AccountIdentityProof', dependent: :destroy, inverse_of: :account
# Timelines
has_many :stream_entries, inverse_of: :account, dependent: :destroy
has_many :statuses, inverse_of: :account, dependent: :destroy
has_many :favourites, inverse_of: :account, dependent: :destroy
has_many :mentions, inverse_of: :account, dependent: :destroy

View file

@ -1,43 +0,0 @@
# frozen_string_literal: true
module Streamable
extend ActiveSupport::Concern
included do
has_one :stream_entry, as: :activity
after_create do
account.stream_entries.create!(activity: self, hidden: hidden?) if needs_stream_entry?
end
end
def title
super
end
def content
title
end
def target
super
end
def object_type
:activity
end
def thread
super
end
def hidden?
false
end
private
def needs_stream_entry?
account.local?
end
end

View file

@ -1,57 +0,0 @@
# frozen_string_literal: true
class RemoteProfile
include ActiveModel::Model
attr_reader :document
def initialize(body)
@document = Nokogiri::XML.parse(body, nil, 'utf-8')
end
def root
@root ||= document.at_xpath('/atom:feed|/atom:entry', atom: OStatus::TagManager::XMLNS)
end
def author
@author ||= root.at_xpath('./atom:author|./dfrn:owner', atom: OStatus::TagManager::XMLNS, dfrn: OStatus::TagManager::DFRN_XMLNS)
end
def hub_link
@hub_link ||= link_href_from_xml(root, 'hub')
end
def display_name
@display_name ||= author.at_xpath('./poco:displayName', poco: OStatus::TagManager::POCO_XMLNS)&.content
end
def note
@note ||= author.at_xpath('./atom:summary|./poco:note', atom: OStatus::TagManager::XMLNS, poco: OStatus::TagManager::POCO_XMLNS)&.content
end
def scope
@scope ||= author.at_xpath('./mastodon:scope', mastodon: OStatus::TagManager::MTDN_XMLNS)&.content
end
def avatar
@avatar ||= link_href_from_xml(author, 'avatar')
end
def header
@header ||= link_href_from_xml(author, 'header')
end
def emojis
@emojis ||= author.xpath('./xmlns:link[@rel="emoji"]', xmlns: OStatus::TagManager::XMLNS)
end
def locked?
scope == 'private'
end
private
def link_href_from_xml(xml, type)
xml.at_xpath(%(./atom:link[@rel="#{type}"]/@href), atom: OStatus::TagManager::XMLNS)&.content
end
end

View file

@ -28,7 +28,6 @@ class Status < ApplicationRecord
before_destroy :unlink_from_conversations
include Paginable
include Streamable
include Cacheable
include StatusThreadingConcern
@ -61,7 +60,6 @@ class Status < ApplicationRecord
has_and_belongs_to_many :preview_cards
has_one :notification, as: :activity, dependent: :destroy
has_one :stream_entry, as: :activity, inverse_of: :status
has_one :status_stat, inverse_of: :status
has_one :poll, inverse_of: :status, dependent: :destroy
@ -106,13 +104,11 @@ class Status < ApplicationRecord
:status_stat,
:tags,
:preview_cards,
:stream_entry,
:preloadable_poll,
account: :account_stat,
active_mentions: { account: :account_stat },
reblog: [
:application,
:stream_entry,
:tags,
:preview_cards,
:media_attachments,

View file

@ -1,59 +0,0 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: stream_entries
#
# id :bigint(8) not null, primary key
# activity_id :bigint(8)
# activity_type :string
# created_at :datetime not null
# updated_at :datetime not null
# hidden :boolean default(FALSE), not null
# account_id :bigint(8)
#
class StreamEntry < ApplicationRecord
include Paginable
belongs_to :account, inverse_of: :stream_entries
belongs_to :activity, polymorphic: true
belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id', inverse_of: :stream_entry
validates :account, :activity, presence: true
STATUS_INCLUDES = [:account, :stream_entry, :conversation, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :conversation, :media_attachments, :tags, mentions: :account], thread: [:stream_entry, :account]].freeze
default_scope { where(activity_type: 'Status') }
scope :recent, -> { reorder(id: :desc) }
scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) }
delegate :target, :title, :content, :thread,
to: :status,
allow_nil: true
def object_type
orphaned? || targeted? ? :activity : status.object_type
end
def verb
orphaned? ? :delete : status.verb
end
def targeted?
[:follow, :request_friend, :authorize, :reject, :unfollow, :block, :unblock, :share, :favorite].include? verb
end
def threaded?
(verb == :favorite || object_type == :comment) && !thread.nil?
end
def mentions
orphaned? ? [] : status.active_mentions.map(&:account)
end
private
def orphaned?
status.nil?
end
end