5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 11:46:22 +00:00

fix: no duplicar código

This commit is contained in:
f 2024-03-01 17:29:08 -03:00
parent 22f730b805
commit 85c45d4823
No known key found for this signature in database
2 changed files with 3 additions and 7 deletions

View file

@ -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

View file

@ -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