Debian Codegraph @

plugin/mastodon_sse_streaming/handler/reblog.rb

raw symbols SCIP
1 # frozen_string_literal: true
2
3 module Plugin::MastodonSseStreaming::Handler
4 class Reblog
5 # @param [Plugin::Mastodon::SSEAuthorizedType|Plugin::Mastodon::SSEPublicType] connection_type
6 # @yield [user, message] SSEで受信したreblogひとつにつき一度呼ばれる
7 # @yieldparam [Plugin::Mastodon::Account] user Boostしたユーザ
8 # @yieldparam [Plugin::Mastodon::Status] message BoostされたToot
9 def initialize(connection_type, &receiver)
10 @connection_type = connection_type
11 @receiver = receiver
12 end
13
14 # @params [String] event
15 # @params [Hash] payload
16 def call(event, payload)
17 return if event != 'notification'
18 case payload
19 in type: 'reblog', account: Hash => account, status: Hash => status
20 @receiver.(Plugin::Mastodon::Account.new(account),
21 Plugin::Mastodon::Status.build(@connection_type.server, status))
22 else
23 # noop
24 end
25 end
26 end
27 end