diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-07-28 17:47:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-28 17:47:37 +0200 |
commit | b9b0313c78ca4efcc8cda089c652be0b333aa16a (patch) | |
tree | 7f94dada733b514a2034839c3ca6fb6776487250 /app/lib/activitypub | |
parent | 75f7f9930eb2a6f5c4041ec44fe0aa795c9ec449 (diff) |
Revert "Remove conversation URI (#11423)" (#11424)
This reverts commit 75f7f9930eb2a6f5c4041ec44fe0aa795c9ec449.
Diffstat (limited to 'app/lib/activitypub')
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index eb7b09e44..000b77df5 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -67,6 +67,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity sensitive: @object['sensitive'] || false, visibility: visibility_from_audience, thread: replied_to_status, + conversation: conversation_from_uri(@object['conversation']), media_attachment_ids: process_attachments.take(4).map(&:id), poll: process_poll, } @@ -261,6 +262,16 @@ class ActivityPub::Activity::Create < ActivityPub::Activity ActivityPub::FetchRepliesWorker.perform_async(status.id, uri) unless uri.nil? end + def conversation_from_uri(uri) + return nil if uri.nil? + return Conversation.find_by(id: OStatus::TagManager.instance.unique_tag_to_local_id(uri, 'Conversation')) if OStatus::TagManager.instance.local_id?(uri) + begin + Conversation.find_or_create_by!(uri: uri) + rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique + retry + end + end + def visibility_from_audience if equals_or_includes?(@object['to'], ActivityPub::TagManager::COLLECTIONS[:public]) :public |