Debian Codegraph @

plugin/mastodon_sse_streaming/handler/poll.rb

raw symbols SCIP
1 # frozen_string_literal: true
2
3 module Plugin::MastodonSseStreaming::Handler
4 class Poll
5 # @param [Plugin::Mastodon::SSEAuthorizedType|Plugin::Mastodon::SSEPublicType] connection_type
6 # @yield [user, message] SSEで受信したpollひとつにつき一度呼ばれる
7 # @yieldparam [Plugin::Mastodon::Status] message 投票が締め切られたToot
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: 'poll', status: Hash => status
19 @receiver.(Plugin::Mastodon::Status.build(@connection_type.server, status))
20 else
21 # noop
22 end
23 end
24 end
25 end