Adding more unit tests. Fixing Salmon slaps XML
This commit is contained in:
parent
446267d1bf
commit
720ff55262
13 changed files with 363 additions and 58 deletions
|
@ -167,6 +167,52 @@ module AtomBuilderHelper
|
|||
end
|
||||
end
|
||||
|
||||
def include_target(xml, target)
|
||||
simple_id xml, TagManager.instance.uri_for(target)
|
||||
|
||||
if target.object_type == :person
|
||||
include_author xml, target
|
||||
else
|
||||
object_type xml, target.object_type
|
||||
verb xml, target.verb
|
||||
title xml, target.title
|
||||
link_alternate xml, TagManager.instance.url_for(target)
|
||||
end
|
||||
|
||||
# Statuses have content and author
|
||||
return unless target.is_a?(Status)
|
||||
|
||||
rich_content xml, target
|
||||
verb xml, target.verb
|
||||
published_at xml, target.created_at
|
||||
updated_at xml, target.updated_at
|
||||
|
||||
author(xml) do
|
||||
include_author xml, target.account
|
||||
end
|
||||
|
||||
if target.reply?
|
||||
in_reply_to xml, TagManager.instance.uri_for(target.thread), TagManager.instance.url_for(target.thread)
|
||||
end
|
||||
|
||||
link_visibility xml, target
|
||||
|
||||
target.mentions.each do |mention|
|
||||
link_mention xml, mention.account
|
||||
end
|
||||
|
||||
target.media_attachments.each do |media|
|
||||
link_enclosure xml, media
|
||||
end
|
||||
|
||||
target.tags.each do |tag|
|
||||
category xml, tag.name
|
||||
end
|
||||
|
||||
category(xml, 'nsfw') if target.sensitive?
|
||||
privacy_scope(xml, target.visibility)
|
||||
end
|
||||
|
||||
def include_entry(xml, stream_entry)
|
||||
unique_id xml, stream_entry.created_at, stream_entry.activity_id, stream_entry.activity_type
|
||||
published_at xml, stream_entry.created_at
|
||||
|
@ -185,45 +231,7 @@ module AtomBuilderHelper
|
|||
|
||||
if stream_entry.targeted?
|
||||
target(xml) do
|
||||
simple_id xml, TagManager.instance.uri_for(stream_entry.target)
|
||||
|
||||
if stream_entry.target.object_type == :person
|
||||
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
|
||||
|
||||
# Statuses have content and author
|
||||
if stream_entry.target.is_a?(Status)
|
||||
rich_content xml, stream_entry.target
|
||||
verb xml, stream_entry.target.verb
|
||||
published_at xml, stream_entry.target.created_at
|
||||
updated_at xml, stream_entry.target.updated_at
|
||||
|
||||
author(xml) do
|
||||
include_author xml, stream_entry.target.account
|
||||
end
|
||||
|
||||
link_visibility xml, stream_entry.target
|
||||
|
||||
stream_entry.target.mentions.each do |mention|
|
||||
link_mention xml, mention.account
|
||||
end
|
||||
|
||||
stream_entry.target.media_attachments.each do |media|
|
||||
link_enclosure xml, media
|
||||
end
|
||||
|
||||
stream_entry.target.tags.each do |tag|
|
||||
category xml, tag.name
|
||||
end
|
||||
|
||||
category(xml, 'nsfw') if stream_entry.target.sensitive?
|
||||
privacy_scope(xml, stream_entry.target.visibility)
|
||||
end
|
||||
include_target(xml, stream_entry.target)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -31,14 +31,10 @@ class FavouriteService < BaseService
|
|||
end
|
||||
|
||||
object_type xml, :activity
|
||||
verb xml, :favourite
|
||||
verb xml, :favorite
|
||||
|
||||
target(xml) do
|
||||
author(xml) do
|
||||
include_author xml, favourite.status.account
|
||||
end
|
||||
|
||||
include_entry xml, favourite.status.stream_entry
|
||||
include_target xml, favourite.status
|
||||
end
|
||||
end
|
||||
end.to_xml
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
class FetchAtomService < BaseService
|
||||
def call(url)
|
||||
return if url.blank?
|
||||
|
||||
response = http_client.head(url)
|
||||
|
||||
Rails.logger.debug "Remote status HEAD request returned code #{response.code}"
|
||||
|
|
|
@ -22,14 +22,10 @@ class UnfavouriteService < BaseService
|
|||
end
|
||||
|
||||
object_type xml, :activity
|
||||
verb xml, :unfavourite
|
||||
verb xml, :unfavorite
|
||||
|
||||
target(xml) do
|
||||
author(xml) do
|
||||
include_author xml, favourite.status.account
|
||||
end
|
||||
|
||||
include_entry xml, favourite.status.stream_entry
|
||||
include_target xml, favourite.status
|
||||
end
|
||||
end
|
||||
end.to_xml
|
||||
|
|
|
@ -9,7 +9,7 @@ class AfterRemoteFollowRequestWorker
|
|||
follow_request = FollowRequest.find(follow_request_id)
|
||||
updated_account = FetchRemoteAccountService.new.call(follow_request.target_account.remote_url)
|
||||
|
||||
return if updated_account.locked?
|
||||
return if updated_account.nil? || updated_account.locked?
|
||||
|
||||
follow_request.destroy
|
||||
FollowService.new.call(follow_request.account, updated_account.acct)
|
||||
|
|
|
@ -9,7 +9,7 @@ class AfterRemoteFollowWorker
|
|||
follow = Follow.find(follow_id)
|
||||
updated_account = FetchRemoteAccountService.new.call(follow.target_account.remote_url)
|
||||
|
||||
return unless updated_account.locked?
|
||||
return if updated_account.nil? || !updated_account.locked?
|
||||
|
||||
follow.destroy
|
||||
FollowService.new.call(follow.account, updated_account.acct)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue