mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 11:06:23 +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]
|
||||
def object_uri
|
||||
@object_uri ||=
|
||||
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
|
||||
@object_uri ||= ::ActivityPub.uri_from_object(original_activity[:object])
|
||||
ensure
|
||||
raise ActiveRecord::RecordNotFound, 'object id missing' if @object_uri.blank?
|
||||
end
|
||||
|
|
|
@ -24,8 +24,9 @@ class ActivityPub < ApplicationRecord
|
|||
# @return [String, nil]
|
||||
def self.uri_from_object(object)
|
||||
case object
|
||||
when Array then uri_from_object(object.first)
|
||||
when String then object
|
||||
when Hash then object['id']
|
||||
when Hash then (object['id'] || object[:id])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue