Debian Codegraph @

plugin/mastodon_sse_streaming/handler/follow.rb

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