about summary refs log tree commit diff
path: root/app/lib/ostatus/activity
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-09-01 20:34:04 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-09-01 13:34:04 +0200
commit504737e860a13f9636fc47131ff27238236e8971 (patch)
tree10672c1d0dba229f5f416f03e09aae072f01386e /app/lib/ostatus/activity
parentaf2d22f88cf84313e11a5f0b1f3a1170f721967e (diff)
Convert OStatus tag to ActivityPub id on in_reply_to resolution (#4756)
Diffstat (limited to 'app/lib/ostatus/activity')
-rw-r--r--app/lib/ostatus/activity/base.rb10
-rw-r--r--app/lib/ostatus/activity/creation.rb2
2 files changed, 11 insertions, 1 deletions
diff --git a/app/lib/ostatus/activity/base.rb b/app/lib/ostatus/activity/base.rb
index da9a01759..1dc7abee3 100644
--- a/app/lib/ostatus/activity/base.rb
+++ b/app/lib/ostatus/activity/base.rb
@@ -56,6 +56,16 @@ class OStatus::Activity::Base
     Status.find_by(uri: uri)
   end
 
+  def find_activitypub_status(uri, href)
+    tag_matches = /tag:([^,:]+)[^:]*:objectId=([\d]+)/.match(uri)
+    href_matches = %r{/users/([^/]+)}.match(href)
+
+    unless tag_matches.nil? || href_matches.nil?
+      uri = "https://#{tag_matches[1]}/users/#{href_matches[1]}/statuses/#{tag_matches[2]}"
+      Status.find_by(uri: uri)
+    end
+  end
+
   def redis
     Redis.current
   end
diff --git a/app/lib/ostatus/activity/creation.rb b/app/lib/ostatus/activity/creation.rb
index b28239a05..1a23c9efa 100644
--- a/app/lib/ostatus/activity/creation.rb
+++ b/app/lib/ostatus/activity/creation.rb
@@ -36,7 +36,7 @@ class OStatus::Activity::Creation < OStatus::Activity::Base
         language: content_language,
         visibility: visibility_scope,
         conversation: find_or_create_conversation,
-        thread: thread? ? find_status(thread.first) : nil
+        thread: thread? ? find_status(thread.first) || find_activitypub_status(thread.first, thread.second) : nil
       )
 
       save_mentions(status)