aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorToshiaki Asai <toshi.alternative@gmail.com>2016-10-06 04:35:45 +0900
committerToshiaki Asai <toshi.alternative@gmail.com>2016-10-06 05:03:42 +0900
commit538da0c3c3f870a71e20dd04ecf9b8bc58d0d534 (patch)
tree1c2081a9d3cee35889daedac1c4835ab77b12058 /core
parent6c75b178b17729ac4d60592f60144958653aabbe (diff)
downloadmikutter-538da0c3c3f870a71e20dd04ecf9b8bc58d0d534.tar.gz
MessageのpermalinkからMessageを作成する手段 refs #866
Diffstat (limited to 'core')
-rw-r--r--core/message.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/core/message.rb b/core/message.rb
index 221a5aa2..49bec4d7 100644
--- a/core/message.rb
+++ b/core/message.rb
@@ -60,7 +60,23 @@ class Message < Retriever::Model
entity_class Retriever::Entity::TwitterEntity
- handle PermalinkMatcher
+ handle PermalinkMatcher do |uri|
+ match = PermalinkMatcher.match(uri.to_s)
+ notice match.inspect
+ if match
+ message = findbyid(match[:id].to_i, Retriever::DataSource::USE_LOCAL_ONLY)
+ notice message.inspect
+ if message
+ message
+ else
+ Thread.new do
+ findbyid(match[:id].to_i, Retriever::DataSource::USE_ALL)
+ end
+ end
+ else
+ raise Retriever::RetrieverError, "id##{match[:id]} does not exist in #{self}."
+ end
+ end
def self.container_class
Messages end