Browse Source

匿名使用汉字编号

pull/4/head
欧醚 4 years ago
parent
commit
b39c079cec
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      app/controllers/api/v1/statuses_controller.rb

+ 5
- 1
app/controllers/api/v1/statuses_controller.rb View File

@ -37,11 +37,15 @@ class Api::V1::StatusesController < Api::BaseController
render json: @context, serializer: REST::ContextSerializer, relationships: StatusRelationshipsPresenter.new(statuses, current_user&.account_id)
end
def to_cn(n)
"甲乙丙丁戊己庚辛壬癸"[n % 10] + [n % 20873, n % 20899].map{|i| i+0x4e00}.pack('U*')
end
def create
thread = status_params[:in_reply_to_id].blank? ? nil : Status.find(status_params[:in_reply_to_id])
masked = status_params[:status].end_with?('[mask]')
sender = masked ? Account.find_local('mask_bot') : current_account
st_text = masked ? ("$#{(7919**(current_account.id + 1000 * Time.new.day) % 10000000007).to_s(16)}: " + status_params[:status][0..4900]) : status_params[:status]
st_text = masked ? ("$#{to_cn(7919**(current_account.id + 1000 * Time.new.day) % 10000000007)}: " + status_params[:status][0..4900]) : status_params[:status]
@status = PostStatusService.new.call(sender,
text: st_text,

Loading…
Cancel
Save