diff --git a/.rubocop.yml b/.rubocop.yml index bf92819..f1d22d3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +AllCops: + NewCops: enable + Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes @@ -9,9 +12,6 @@ Style/StringLiteralsInInterpolation: Layout/LineLength: Max: 190 -Metrics/BlockLength: - Max: 60 - Metrics/ParameterLists: Max: 8 diff --git a/lib/activitypub/actor.rb b/lib/activitypub/actor.rb index bb2d5f6..902f526 100644 --- a/lib/activitypub/actor.rb +++ b/lib/activitypub/actor.rb @@ -17,7 +17,7 @@ module ActivityPub class Actor attr_accessor :id, :type, :name, :preferred_username, :inbox, :outbox, :followers, :following - def initialize(id:, type: "Person", name:, preferred_username:, inbox:, outbox:, followers: nil, following: nil) + def initialize(id:, name:, preferred_username:, inbox:, outbox:, type: "Person", followers: nil, following: nil) @id = id @type = type @name = name @@ -58,5 +58,25 @@ def self.from_h(hash) following: hash["following"] ) end + + class Person < Actor + # Attributes and methods specific to a Person actor type. + end + + class Service < Actor + # Attributes and methods specific to a Service actor type. + end + + class Group < Actor + # Attributes and methods specific to a Group actor type. + end + + class Organization < Actor + # Attributes and methods specific to an Organization actor type. + end + + class Application < Actor + # Attributes and methods specific to an Application actor type. + end end end diff --git a/lib/activitypub/outbox.rb b/lib/activitypub/outbox.rb index b629ada..29ea7c4 100644 --- a/lib/activitypub/outbox.rb +++ b/lib/activitypub/outbox.rb @@ -21,12 +21,10 @@ def send_activity(target_inbox_url, activity_data) signature = ActivityPub::Signature.sign(activity_data, private_key) # Send the signed activity to the target actor's inbox - response = post_activity(target_inbox_url, activity_data, signature) + post_activity(target_inbox_url, activity_data, signature) # Save the activity in the outbox (not implemented here for simplicity, but would be in a real-world scenario) # save_activity(activity_data) - - response end private diff --git a/lib/activitypub/signature.rb b/lib/activitypub/signature.rb index 3625205..807fe15 100644 --- a/lib/activitypub/signature.rb +++ b/lib/activitypub/signature.rb @@ -21,7 +21,7 @@ def self.generate_keypair # Signs data with the given private key def self.sign(data, private_key_pem) private_key = OpenSSL::PKey::RSA.new(private_key_pem) - signature = private_key.sign(OpenSSL::Digest::SHA256.new, data) + signature = private_key.sign(OpenSSL::Digest.new("SHA256"), data) Base64.encode64(signature).gsub("\n", "") end @@ -29,7 +29,7 @@ def self.sign(data, private_key_pem) def self.verify?(data, signature, public_key_pem) public_key = OpenSSL::PKey::RSA.new(public_key_pem) signature_decoded = Base64.decode64(signature) - public_key.verify(OpenSSL::Digest::SHA256.new, signature_decoded, data) + public_key.verify(OpenSSL::Digest.new("SHA256"), signature_decoded, data) end end end