diff --git a/app/models/block.rb b/app/models/block.rb index ec9d96e52d9..d9ac463a933 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -13,7 +13,7 @@ # class Block < ApplicationRecord - include ActivityPubPayloadGeneration + include ActivityPub::Identifier include Paginable include RelationshipCacheable diff --git a/app/models/concerns/activity_pub/identifier.rb b/app/models/concerns/activity_pub/identifier.rb new file mode 100644 index 00000000000..d928176749a --- /dev/null +++ b/app/models/concerns/activity_pub/identifier.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module ActivityPub + module Identifier + extend ActiveSupport::Concern + + included do + before_validation :generate_global_identifier, + only: :create, + unless: :uri? + end + + private + + def generate_global_identifier + self.uri = ActivityPub::TagManager + .instance + .generate_activity_uri + end + end +end diff --git a/app/models/concerns/activitypub_payload_generation.rb b/app/models/concerns/activitypub_payload_generation.rb deleted file mode 100644 index 51c7070caa4..00000000000 --- a/app/models/concerns/activitypub_payload_generation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -module ActivityPubPayloadGeneration - extend ActiveSupport::Concern - - included do - before_validation :generate_payload_uri, - only: :create, - unless: :uri? - end - - private - - def generate_payload_uri - self.uri = ActivityPub::TagManager - .instance - .generate_activity_uri - end -end diff --git a/app/models/follow.rb b/app/models/follow.rb index 963f1c23359..f0e1eb02c81 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -16,7 +16,7 @@ # class Follow < ApplicationRecord - include ActivityPubPayloadGeneration + include ActivityPub::Identifier include Paginable include RelationshipCacheable include RateLimitable diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb index 923fc4173cc..32d2b25075d 100644 --- a/app/models/follow_request.rb +++ b/app/models/follow_request.rb @@ -16,7 +16,7 @@ # class FollowRequest < ApplicationRecord - include ActivityPubPayloadGeneration + include ActivityPub::Identifier include Paginable include RelationshipCacheable include RateLimitable