From bfb205c0a404a390c7a121f6461776dee7f1c3d0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 22 May 2024 10:56:52 -0400 Subject: [PATCH] Rename `ActivityPubPayloadGeneration` to `ActivityPub::Identifier` --- app/models/block.rb | 2 +- .../concerns/activity_pub/identifier.rb | 21 +++++++++++++++++++ .../activitypub_payload_generation.rb | 19 ----------------- app/models/follow.rb | 2 +- app/models/follow_request.rb | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 app/models/concerns/activity_pub/identifier.rb delete mode 100644 app/models/concerns/activitypub_payload_generation.rb 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