This commit is contained in:
mgabdev
2020-05-01 01:50:27 -04:00
parent c15d4f12dc
commit 8e349c368c
99 changed files with 1268 additions and 887 deletions

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class HashtagQueryService < BaseService
LIMIT_PER_MODE = 1
def call(tag, params, account = nil, local = false)
tags = tags_for(Array(tag.name) | Array(params[:any])).pluck(:id)
all = tags_for(params[:all])
@@ -14,7 +16,7 @@ class HashtagQueryService < BaseService
private
def tags_for(tags)
Tag.where(name: tags.map(&:downcase)) if tags.presence
def tags_for(names)
Tag.matching_name(Array(names).take(LIMIT_PER_MODE)) if names.present?
end
end
end

View File

@@ -53,7 +53,7 @@ class PostStatusService < BaseService
def preprocess_attributes!
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
@visibility = :unlisted if @visibility == :public && @account.silenced?
@visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced?
@scheduled_at = @options[:scheduled_at]&.to_datetime
@scheduled_at = nil if scheduled_in_the_past?
rescue ArgumentError

View File

@@ -13,7 +13,7 @@ class VoteService < BaseService
ApplicationRecord.transaction do
@choices.each do |choice|
@votes << @poll.votes.create!(account: @account, choice: choice)
@votes << @poll.votes.create!(account: @account, choice: Integer(choice))
end
end