マストドンカスタマイズメモ(自分用)
version 1.2.2の場合。
投稿500文字について
制限について
投稿500文字を変更するには複数個所変更の必要あり。
特に翻訳文字config/locales/*.ymlなどにはハードコーディングされているので注意。
もし投稿後にpost_status_service.rbで文字を増やす場合は、バリデーションに引っかかるので下記のMAX_CHARSを変更する。
./app/validators/status_length_validator.rb
表示について
制限を解除したり500文字以上の投稿がされてもタイムライン上にはだいたい正常に表示される。
DBについて
投稿はstatusesテーブルに格納される。
投稿のメッセージはtextフィールドで、text型なので実質無制限。
Table "public.statuses" Column | Type | Modifiers ------------------------+-----------------------------+------------------------------------------------------- id | bigint | not null default nextval('statuses_id_seq'::regclass) uri | character varying | account_id | integer | not null text | text | not null default ''::text created_at | timestamp without time zone | not null updated_at | timestamp without time zone | not null in_reply_to_id | bigint | reblog_of_id | bigint | url | character varying | sensitive | boolean | default false visibility | integer | not null default 0 in_reply_to_account_id | integer | application_id | integer | spoiler_text | text | not null default ''::text reply | boolean | default false favourites_count | integer | not null default 0 reblogs_count | integer | not null default 0 language | character varying | not null default 'en'::character varying Indexes: "statuses_pkey" PRIMARY KEY, btree (id) "index_statuses_on_uri" UNIQUE, btree (uri) "index_statuses_on_account_id" btree (account_id) "index_statuses_on_in_reply_to_id" btree (in_reply_to_id) "index_statuses_on_reblog_of_id" btree (reblog_of_id) Foreign-key constraints: "fk_rails_256483a9ab" FOREIGN KEY (reblog_of_id) REFERENCES statuses(id) ON DELETE CASCADE Referenced by: TABLE "statuses" CONSTRAINT "fk_rails_256483a9ab" FOREIGN KEY (reblog_of_id) REFERENCES statuses(id) ON DELETE CASCADE
投稿内容を改変する場所
app/services/post_status_service.rb
16行目くらいに入れました。
15 def call(account, text, in_reply_to = nil, options = {})
16 media = validate_media!(options[:media_ids])
17 status = account.statuses.create!(text: text,
18 thread: in_reply_to,
19 sensitive: options[:sensitive],
20 spoiler_text: options[:spoiler_text] || '',
21 visibility: options[:visibility],
22 language: detect_language_for(text, account),
23 application: options[:application])
24
25 attach_media(status, media)
26 process_mentions_service.call(status)
27 process_hashtags_service.call(status)
28
29 LinkCrawlWorker.perform_async(status.id)
30 DistributionWorker.perform_async(status.id)
31 Pubsubhubbub::DistributionWorker.perform_async(status.stream_entry.id)
32
33 status