Add custom_emoji isSensitive support

This commit is contained in:
KMY 2023-05-22 17:44:47 +09:00
parent 156f3a7c99
commit ff2bcf7595
8 changed files with 23 additions and 4 deletions

View file

@ -4,6 +4,7 @@
### 追加
- カスタム絵文字の`isSensitive`値のサポート (from Misskey)
- カスタム絵文字の検索用のエイリアスキーワード
- アンテナの STLソーシャルタイムラインモード
- アカウントの投稿数、フォロー数、フォロワー数の隠蔽

View file

@ -91,6 +91,11 @@ export function normalizeStatus(status, normalOldStatus) {
normalStatus.spoiler_text = '';
}
console.dir(normalStatus.emojis);
if (normalStatus.emojis && normalStatus.emojis.some((emoji) => emoji.is_sensitive) && !normalStatus.spoiler_text) {
normalStatus.spoiler_text = '[Contains sensitive custom emoji(s)]';
}
const spoilerText = normalStatus.spoiler_text || '';
const searchContent = ([spoilerText, status.content].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).concat(status.media_attachments.map(att => att.description)).join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
const emojiMap = makeEmojiMap(normalStatus);

View file

@ -263,7 +263,7 @@ 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)
emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: custom_emoji_parser.shortcode, uri: custom_emoji_parser.uri, is_sensitive: custom_emoji_parser.is_sensitive)
emoji.image_remote_url = custom_emoji_parser.image_remote_url
emoji.save
rescue Seahorse::Client::NetworkingError => e

View file

@ -24,4 +24,8 @@ class ActivityPub::Parser::CustomEmojiParser
rescue ArgumentError
nil
end
def is_sensitive # rubocop:disable Naming/PredicateName
(@json['isSensitive'].presence || false)
end
end

View file

@ -22,6 +22,7 @@
# image_width :integer
# image_height :integer
# aliases :jsonb
# is_sensitive :boolean default(FALSE), not null
#
class CustomEmoji < ApplicationRecord

View file

@ -3,7 +3,7 @@
class REST::CustomEmojiSerializer < ActiveModel::Serializer
include RoutingHelper
attributes :shortcode, :url, :static_url, :visible_in_picker
attributes :shortcode, :url, :static_url, :visible_in_picker, :is_sensitive
attribute :category, if: :category_loaded?
attribute :width, if: :width?

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddIsSensitiveToCustomEmojis < ActiveRecord::Migration[6.1]
def change
add_column :custom_emojis, :is_sensitive, :boolean, null: false, default: false
end
end

View file

@ -12,7 +12,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2023_05_21_122642) do
ActiveRecord::Schema.define(version: 2023_05_22_082252) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -439,6 +439,7 @@ ActiveRecord::Schema.define(version: 2023_05_21_122642) do
t.integer "image_width"
t.integer "image_height"
t.jsonb "aliases"
t.boolean "is_sensitive", default: false, null: false
t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
end
@ -1488,4 +1489,4 @@ ActiveRecord::Schema.define(version: 2023_05_21_122642) do
end
#rubocop:enable all
# rubocop:enable all