这些魔改内容,非常简单,其他博主也发过,就比如

https://pullopen.github.io/%E8%BF%9B%E9%98%B6%E9%AD%94%E6%94%B9/2020/11/14/mastodon-modify.html
https://blog.bgme.me/
https://pullopen.github.io/%E8%BF%9B%E9%98%B6%E9%AD%94%E6%94%B9/2020/11/01/Mastodon-on-Docker-2.html
https://blog.tantalum.life/posts/notes-on-modifying-mastodon-in-docker/
就不一一例举了。

我这大概也算是跟风吧?但是有些内容我在网上中文圈实在是查不到,可能研究的人少,也可能被淹没了。

投票增加

官方长毛象投票只能投4行,实在太少了。你觉得呢?

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/app/validators/poll_validator.rb b/app/validators/poll_validator.rb
index a327277963..fb6dbad38c 100644
--- a/app/validators/poll_validator.rb
+++ b/app/validators/poll_validator.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class PollValidator < ActiveModel::Validator
- MAX_OPTIONS = 4
+ MAX_OPTIONS = 40
MAX_OPTION_CHARS = 50
MAX_EXPIRATION = 1.month.freeze
MIN_EXPIRATION = 5.minutes.freeze

总共需要改1处代码。我改为了最多40个选项。因为我的实例不开放注册,所以投票选项近乎无限,非常不建议公共实例开太多选项,稍微增加一点得了。你必须考虑到会有你不认识的恶意用户用大量投票水贴刷屏!

媒体大小增加

玩象途中,经常会发生媒体文件过大的报错,发个图还不如微博,束手束脚的。所以也果断改了! 但要提醒的是,光靠这一处无限增大,也是无法让你在你的实例上上传电影,它应该是有其他写死的地方作为保险的。同样的,我也不建议彻底放开媒体限制,个人私有的实例也不例外,这是为了你好

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index 6708cd7793..4788ce1414 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -39,8 +39,8 @@ class MediaAttachment < ApplicationRecord

MAX_DESCRIPTION_LENGTH = 1_500

- IMAGE_LIMIT = 16.megabytes
- VIDEO_LIMIT = 99.megabytes
+ IMAGE_LIMIT = 32.megabytes
+ VIDEO_LIMIT = 200.megabytes

MAX_VIDEO_MATRIX_LIMIT = 8_294_400 # 3840x2160px
MAX_VIDEO_FRAME_RATE = 120

嘟文字数增加

微博类服务的特点就是字数少,要在140字内把话说完。但是,长毛象是我们吐露心声的地方,如果500字(官方限制)不够用,那就得开一长串(我才不会搬到博客来发!键政的事就留在长毛象好了)。那么我再稍微改改代码 (以前改的不止这一处,现版本听说优化过了,大大减轻了站长们的负担!)

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/app/validators/status_length_validator.rb b/app/validators/status_length_validator.rb
index dc841ded3e..9cb1ec94b3 100644
--- a/app/validators/status_length_validator.rb
+++ b/app/validators/status_length_validator.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class StatusLengthValidator < ActiveModel::Validator
- MAX_CHARS = 500
+ MAX_CHARS = 5000
URL_PLACEHOLDER_CHARS = 23
URL_PLACEHOLDER = 'x' * 23

置顶限制增加

置顶贴原来的限制为5个。其实没必要增加,但是有的时候,我置顶了5个以后,又想发起投票,在有效期间提高参与度。这样的话,我就得在我的所有置顶当中做出取舍。但最终,我选择了舍弃置顶数量限制😎

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/app/validators/status_pin_validator.rb b/app/validators/status_pin_validator.rb
index c9c1effba8..3868a85718 100644
--- a/app/validators/status_pin_validator.rb
+++ b/app/validators/status_pin_validator.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class StatusPinValidator < ActiveModel::Validator
- PIN_LIMIT = 5
+ PIN_LIMIT = 10

def validate(pin)
pin.errors.add(:base, I18n.t('statuses.pin_errors.reblog')) if pin.status.reblog?

发送多个视频

新浪微博好像只允许会员在一条微博发多个视频?(我被封太久了,不知现在政策如何了,知情的朋友在评论区留个言)
这个政策是因为大量用户使用这个功能会占用大量的系统资源,即使在家开机房,我也是会心疼电费的,所以实例不给别人用😅跑题了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb
index a2f50e901a..126d9b3293 100644
--- a/app/services/update_status_service.rb
+++ b/app/services/update_status_service.rb
@@ -76,7 +76,6 @@ class UpdateStatusService < BaseService
not_found_ids = @options[:media_ids].map(&:to_i) - media_attachments.map(&:id)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_found', ids: not_found_ids.join(', ')) if not_found_ids.any?

- raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if media_attachments.size > 1 && media_attachments.find(&:audio_or_video?)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if media_attachments.any?(&:not_processed?)

media_attachments
diff --git a/app/javascript/mastodon/features/compose/containers/upload_button_container.js b/app/javascript/mastodon/features/compose/containers/upload_button_container.js
index 53528ca3f8..a0532fdac4 100644
--- a/app/javascript/mastodon/features/compose/containers/upload_button_container.js
+++ b/app/javascript/mastodon/features/compose/containers/upload_button_container.js
@@ -13,7 +13,7 @@ const mapStateToProps = state => {
const hasVideoOrAudio = state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')));

return {
- disabled: isUploading || isOverLimit || hasVideoOrAudio,
+ disabled: isUploading || isOverLimit,
resetFileKey: state.getIn(['compose', 'resetFileKey']),
};
};
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index 4cb2b399ff..3d6aa857e6 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -137,7 +137,6 @@ class PostStatusService < BaseService
not_found_ids = @options[:media_ids].map(&:to_i) - @media.map(&:id)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_found', ids: not_found_ids.join(', ')) if not_found_ids.any?

- raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if @media.size > 1 && @media.find(&:audio_or_video?)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if @media.any?(&:not_processed?)
end

个人资料附加信息增加

个人资料的field除了发自己的博客、主页、GitHub和各种乱七八糟的酷东西以外,还要发switch游戏账号,方便交友,所以4个怎么够用呢?

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/app/models/account.rb b/app/models/account.rb
index 708415b6ee..1af6bab511 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -65,7 +65,7 @@ class Account < ApplicationRecord
)

BACKGROUND_REFRESH_INTERVAL = 1.week.freeze
- DEFAULT_FIELDS_SIZE = 4
+ DEFAULT_FIELDS_SIZE = 8
INSTANCE_ACTOR_ID = -99

USERNAME_RE = /[a-z0-9_]+([.-]+[a-z0-9_]+)*/i