diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 2b64b9524d..d119fd58bb 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -263,7 +263,13 @@ class ActivityPub::Activity::Create < ActivityPub::Activity return unless emoji.nil? || custom_emoji_parser.image_remote_url != emoji.image_remote_url || (custom_emoji_parser.updated_at && custom_emoji_parser.updated_at >= emoji.updated_at) begin - emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: custom_emoji_parser.shortcode, uri: custom_emoji_parser.uri, is_sensitive: custom_emoji_parser.is_sensitive) + emoji ||= CustomEmoji.new( + domain: @account.domain, + shortcode: custom_emoji_parser.shortcode, + uri: custom_emoji_parser.uri, + is_sensitive: custom_emoji_parser.is_sensitive, + license: custom_emoji_parser.license + ) emoji.image_remote_url = custom_emoji_parser.image_remote_url emoji.save rescue Seahorse::Client::NetworkingError => e diff --git a/app/lib/activitypub/parser/custom_emoji_parser.rb b/app/lib/activitypub/parser/custom_emoji_parser.rb index 25feb3cf11..481199c72d 100644 --- a/app/lib/activitypub/parser/custom_emoji_parser.rb +++ b/app/lib/activitypub/parser/custom_emoji_parser.rb @@ -28,4 +28,8 @@ class ActivityPub::Parser::CustomEmojiParser def is_sensitive # rubocop:disable Naming/PredicateName (@json['isSensitive'].presence || false) end + + def license + @json['license'] + end end diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index f74e034503..6068a6b08d 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -23,6 +23,7 @@ # image_height :integer # aliases :jsonb # is_sensitive :boolean default(FALSE), not null +# license :string # class CustomEmoji < ApplicationRecord diff --git a/db/migrate/20230522093135_add_license_to_custom_emojis.rb b/db/migrate/20230522093135_add_license_to_custom_emojis.rb new file mode 100644 index 0000000000..9e96552023 --- /dev/null +++ b/db/migrate/20230522093135_add_license_to_custom_emojis.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddLicenseToCustomEmojis < ActiveRecord::Migration[6.1] + def change + add_column :custom_emojis, :license, :string, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index b362bdd571..eaee2919e0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,7 +12,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_05_22_082252) do +ActiveRecord::Schema.define(version: 2023_05_22_093135) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -440,6 +440,7 @@ ActiveRecord::Schema.define(version: 2023_05_22_082252) do t.integer "image_height" t.jsonb "aliases" t.boolean "is_sensitive", default: false, null: false + t.string "license" t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true end