Merge remote-tracking branch 'parent/main' into kbtopic-remove-quote
This commit is contained in:
commit
80542ea172
76 changed files with 658 additions and 390 deletions
|
@ -142,11 +142,37 @@ class AccountSearchService < BaseService
|
|||
|
||||
def core_query
|
||||
{
|
||||
multi_match: {
|
||||
query: @query,
|
||||
type: 'best_fields',
|
||||
fields: %w(username^2 display_name^2 text text.*),
|
||||
operator: 'and',
|
||||
dis_max: {
|
||||
queries: [
|
||||
{
|
||||
match: {
|
||||
username: {
|
||||
query: @query,
|
||||
analyzer: 'word_join_analyzer',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
match: {
|
||||
display_name: {
|
||||
query: @query,
|
||||
analyzer: 'word_join_analyzer',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
multi_match: {
|
||||
query: @query,
|
||||
type: 'best_fields',
|
||||
fields: %w(text text.*),
|
||||
operator: 'and',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
tie_breaker: 0.5,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
|
|
@ -3,18 +3,24 @@
|
|||
class CreateFeaturedTagService < BaseService
|
||||
include Payloadable
|
||||
|
||||
def call(account, name, force: true)
|
||||
def call(account, name_or_tag, raise_error: true)
|
||||
raise ArgumentError unless account.local?
|
||||
|
||||
@account = account
|
||||
|
||||
FeaturedTag.create!(account: account, name: name).tap do |featured_tag|
|
||||
ActivityPub::AccountRawDistributionWorker.perform_async(build_json(featured_tag), account.id) if @account.local?
|
||||
end
|
||||
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid => e
|
||||
if force && e.is_a(ActiveRecord::RecordNotUnique)
|
||||
FeaturedTag.by_name(name).find_by!(account: account)
|
||||
else
|
||||
account.featured_tags.new(name: name)
|
||||
@featured_tag = begin
|
||||
if name_or_tag.is_a?(Tag)
|
||||
account.featured_tags.find_or_initialize_by(tag: name_or_tag)
|
||||
else
|
||||
account.featured_tags.find_or_initialize_by(name: name_or_tag)
|
||||
end
|
||||
end
|
||||
|
||||
create_method = raise_error ? :save! : :save
|
||||
|
||||
ActivityPub::AccountRawDistributionWorker.perform_async(build_json(@featured_tag), @account.id) if @featured_tag.new_record? && @featured_tag.public_send(create_method)
|
||||
|
||||
@featured_tag
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -3,11 +3,24 @@
|
|||
class RemoveFeaturedTagService < BaseService
|
||||
include Payloadable
|
||||
|
||||
def call(account, featured_tag)
|
||||
def call(account, featured_tag_or_tag)
|
||||
raise ArgumentError unless account.local?
|
||||
|
||||
@account = account
|
||||
|
||||
featured_tag.destroy!
|
||||
ActivityPub::AccountRawDistributionWorker.perform_async(build_json(featured_tag), account.id) if @account.local?
|
||||
@featured_tag = begin
|
||||
if featured_tag_or_tag.is_a?(FeaturedTag)
|
||||
featured_tag_or_tag
|
||||
elsif featured_tag_or_tag.is_a?(Tag)
|
||||
FeaturedTag.find_by(account: account, tag: featured_tag_or_tag)
|
||||
end
|
||||
end
|
||||
|
||||
return if @featured_tag.nil?
|
||||
|
||||
@featured_tag.destroy!
|
||||
|
||||
ActivityPub::AccountRawDistributionWorker.perform_async(build_json(@featured_tag), account.id) if @account.local?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue