Skip to content

Commit

Permalink
Merge pull request #826 from pooza/3_0_33
Browse files Browse the repository at this point in the history
3.0.33
  • Loading branch information
pooza authored Jul 7, 2022
2 parents 43c5503 + deeb19f commit 0ce4ef5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
15 changes: 8 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ GEM
mime-types-data (3.2022.0105)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.16.1)
msgpack (1.5.2)
minitest (5.16.2)
msgpack (1.5.3)
multi_json (1.15.0)
multi_xml (0.6.0)
mustermann (1.1.1)
Expand Down Expand Up @@ -174,10 +174,10 @@ GEM
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.6.0)
rack (2.2.3.1)
rack (2.2.4)
rack-protection (2.2.0)
rack
rack-test (2.0.0)
rack-test (2.0.2)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand All @@ -202,7 +202,8 @@ GEM
ricecream (0.2.1)
rss (0.2.9)
rexml
rubocop (1.31.0)
rubocop (1.31.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
Expand Down Expand Up @@ -232,7 +233,7 @@ GEM
sassc (2.4.0)
ffi (~> 1.9)
securerandom (0.2.0)
sequel (5.57.0)
sequel (5.58.0)
set (1.0.2)
sidekiq (6.4.2)
connection_pool (>= 2.2.2)
Expand Down Expand Up @@ -308,4 +309,4 @@ RUBY VERSION
ruby 3.1.2p20

BUNDLED WITH
2.3.16
2.3.17
12 changes: 10 additions & 2 deletions app/lib/makoto/responder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ def account
end

def display_name
name = account&.nickname || @params['account']['display_name'].sub(/:$/, ': ')
name += config['/respond/suffix'] unless account.friendry?
unless name = account&.nickname
if display_name = @params.dig('account', 'display_name')
name = display_name.split(/[@@]/).first.sub(/:$/, ': ')
elsif acct = @params.dig('account', 'acct')
name = acct
else
name = 'ジョー岡田'
end
end
name += config['/respond/suffix'] if Environment.test? || !account.friendry?
return name
end

Expand Down
2 changes: 1 addition & 1 deletion config/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ package:
- tkoishi@b-shock.co.jp
license: MIT
url: https://github.com/pooza/makoto
version: 3.0.32
version: 3.0.33
postgres:
dsn: postgres://postgres:password@localhost:5432/makoto
puma:
Expand Down
27 changes: 27 additions & 0 deletions test/responder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Makoto
class ResponderTest < TestCase
def setup
@responder = Responder.new
end

def test_display_name
@responder.params = {account: {display_name: '吟醸院天才郎', acct: '@pooza@precure.ml'}}
assert_equal('吟醸院天才郎さん', @responder.display_name)

@responder.params = {account: {display_name: nil, acct: '@pooza@precure.ml'}}
assert_equal('@pooza@precure.mlさん', @responder.display_name)

@responder.params = {account: {display_name: 'ぷーざ :netabare:', acct: '@pooza@precure.ml'}}
assert_equal('ぷーざ :netabare: さん', @responder.display_name)

@responder.params = {account: {display_name: 'ぷーざ@キュアスタ!', acct: '@pooza@precure.ml'}}
assert_equal('ぷーざさん', @responder.display_name)

@responder.params = {account: {display_name: 'ぷーざ@キュアスタ!', acct: '@pooza@precure.ml'}}
assert_equal('ぷーざさん', @responder.display_name)

@responder.params = {account: {display_name: nil, acct: nil}}
assert_equal('ジョー岡田さん', @responder.display_name)
end
end
end

0 comments on commit 0ce4ef5

Please sign in to comment.