バグ #1285 » 0001-Filterstream-RT-quoted_status_permalink.patch
core/plugin/twitter/twitter.rb | ||
---|---|---|
335 | 335 |
# Twitter Entity情報を元にScoreをあれする |
336 | 336 |
filter_score_filter do |message, note, yielder| |
337 | 337 |
if message == note && %i<twitter_tweet twitter_direct_message>.include?(message.class.slug) |
338 |
score = score_by_entity(message) + extended_entity_media(message) |
|
338 |
score = score_by_entity(message) + quoted_status_permalink(message) + extended_entity_media(message)
|
|
339 | 339 |
if !score.all?{|n| n.class.slug == :score_text } |
340 | 340 |
yielder << score |
341 | 341 |
end |
... | ... | |
398 | 398 |
score |
399 | 399 |
end |
400 | 400 | |
401 |
# filterstream では引用RTの URLが本文に付与されないので quoted_status_permalink から取り出す |
|
402 |
def quoted_status_permalink(tweet) |
|
403 |
score = Array.new |
|
404 |
permalink = (tweet[:quoted_status_permalink] rescue nil) |
|
405 |
if permalink |
|
406 |
uri = Diva::URI.new(permalink[:expanded] || permalink[:url]) |
|
407 |
uri.freeze |
|
408 |
result = Diva::Model(:score_hyperlink).new( |
|
409 |
description: permalink[:display] || permalink[:expanded] || permalink[:url], |
|
410 |
uri: uri) |
|
411 |
# filterstream で流れてくる tweet には :full_text がないのでとりあえずそれで判定 |
|
412 |
# filterstream で本文にすでに URL が含まれている場合があるのかどうかわからないけど |
|
413 |
# それもとりあえず除外 |
|
414 |
full_text = (tweet[:full_text] rescue nil) |
|
415 |
if !full_text || !full_text.include?(permalink[:url]) |
|
416 |
score << text_note(description: ' ') |
|
417 |
score << result |
|
418 |
end |
|
419 |
end |
|
420 |
score |
|
421 |
end |
|
422 | ||
401 | 423 |
def extended_entity_media(tweet) |
402 | 424 |
extended_entities = (tweet[:extended_entities][:media] rescue nil) |
403 | 425 |
if extended_entities |