mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 11:36:21 +00:00
fix: no duplicar código
This commit is contained in:
parent
22f730b805
commit
85c45d4823
2 changed files with 3 additions and 7 deletions
|
@ -89,12 +89,7 @@ module Api
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def object_uri
|
def object_uri
|
||||||
@object_uri ||=
|
@object_uri ||= ::ActivityPub.uri_from_object(original_activity[:object])
|
||||||
case original_activity[:object]
|
|
||||||
when Array then original_activity[:object].first
|
|
||||||
when String then original_activity[:object]
|
|
||||||
when Hash then original_activity.dig(:object, :id)
|
|
||||||
end
|
|
||||||
ensure
|
ensure
|
||||||
raise ActiveRecord::RecordNotFound, 'object id missing' if @object_uri.blank?
|
raise ActiveRecord::RecordNotFound, 'object id missing' if @object_uri.blank?
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,8 +24,9 @@ class ActivityPub < ApplicationRecord
|
||||||
# @return [String, nil]
|
# @return [String, nil]
|
||||||
def self.uri_from_object(object)
|
def self.uri_from_object(object)
|
||||||
case object
|
case object
|
||||||
|
when Array then uri_from_object(object.first)
|
||||||
when String then object
|
when String then object
|
||||||
when Hash then object['id']
|
when Hash then (object['id'] || object[:id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue