| 1 |
|
| 2 |
|
| 3 |
module Plugin::MastodonSseStreaming::Handler |
| 4 |
class Favorite |
| 5 |
|
| 6 |
ひとつにつき一度呼ばれる |
| 7 |
ぼったユーザ |
| 8 |
られたToot |
| 9 |
def initialize(connection_type, &receiver) |
| 10 |
@connection_type = connection_type |
| 11 |
@receiver = receiver |
| 12 |
end |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
def call(event, payload) |
| 17 |
return if event != 'notification' |
| 18 |
case payload |
| 19 |
in type: 'favourite', account: Hash => account, status: Hash => status |
| 20 |
user = Plugin::Mastodon::Account.new(account) |
| 21 |
message = Plugin::Mastodon::Status.build(@connection_type.server, status) |
| 22 |
message.favorite_accts << user.acct |
| 23 |
message.set_modified(Time.now.localtime) if favorite_age?(user) |
| 24 |
@receiver.(user, message) |
| 25 |
else |
| 26 |
|
| 27 |
end |
| 28 |
end |
| 29 |
|
| 30 |
private |
| 31 |
|
| 32 |
def favorite_age?(user) |
| 33 |
if user.me? |
| 34 |
UserConfig[:favorited_by_myself_age] |
| 35 |
else |
| 36 |
UserConfig[:favorited_by_anyone_age] |
| 37 |
end |
| 38 |
end |
| 39 |
end |
| 40 |
end |