activitypub-academy/app/lib/activity_log_event.rb

20 lines
477 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class ActivityLogEvent
2023-02-05 03:07:01 +09:00
attr_accessor :type, :sender, :path, :data, :timestamp
2022-12-09 02:27:05 +09:00
2023-01-05 01:29:24 +09:00
def self.from_json_string(json_string)
json = Oj.load(json_string, mode: :strict)
2023-02-05 03:07:01 +09:00
ActivityLogEvent.new(json['type'], json['sender'], json['path'], json['data'])
2022-12-09 02:27:05 +09:00
end
2023-01-05 01:29:24 +09:00
2023-02-05 03:07:01 +09:00
def initialize(type, sender, path, data, timestamp = Time.now.utc.iso8601)
2023-01-05 01:29:24 +09:00
@type = type
2023-02-05 03:07:01 +09:00
@sender = sender
2023-01-05 01:29:24 +09:00
@path = path
@data = data
2023-01-05 23:19:31 +09:00
@timestamp = timestamp
2023-01-05 01:29:24 +09:00
end
end