about summary refs log tree commit diff
path: root/app/lib/tag_manager.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/tag_manager.rb')
-rw-r--r--app/lib/tag_manager.rb32
1 files changed, 22 insertions, 10 deletions
diff --git a/app/lib/tag_manager.rb b/app/lib/tag_manager.rb
index 2508eea97..2a5e7a409 100644
--- a/app/lib/tag_manager.rb
+++ b/app/lib/tag_manager.rb
@@ -7,15 +7,18 @@ class TagManager
   include RoutingHelper
 
   VERBS = {
-    post:       'http://activitystrea.ms/schema/1.0/post',
-    share:      'http://activitystrea.ms/schema/1.0/share',
-    favorite:   'http://activitystrea.ms/schema/1.0/favorite',
-    unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite',
-    delete:     'http://activitystrea.ms/schema/1.0/delete',
-    follow:     'http://activitystrea.ms/schema/1.0/follow',
-    unfollow:   'http://ostatus.org/schema/1.0/unfollow',
-    block:      'http://mastodon.social/schema/1.0/block',
-    unblock:    'http://mastodon.social/schema/1.0/unblock',
+    post:           'http://activitystrea.ms/schema/1.0/post',
+    share:          'http://activitystrea.ms/schema/1.0/share',
+    favorite:       'http://activitystrea.ms/schema/1.0/favorite',
+    unfavorite:     'http://activitystrea.ms/schema/1.0/unfavorite',
+    delete:         'http://activitystrea.ms/schema/1.0/delete',
+    follow:         'http://activitystrea.ms/schema/1.0/follow',
+    request_friend: 'http://activitystrea.ms/schema/1.0/request-friend',
+    authorize:      'http://activitystrea.ms/schema/1.0/authorize',
+    reject:         'http://activitystrea.ms/schema/1.0/reject',
+    unfollow:       'http://ostatus.org/schema/1.0/unfollow',
+    block:          'http://mastodon.social/schema/1.0/block',
+    unblock:        'http://mastodon.social/schema/1.0/unblock',
   }.freeze
 
   TYPES = {
@@ -38,6 +41,7 @@ class TagManager
   POCO_XMLNS  = 'http://portablecontacts.net/spec/1.0'
   DFRN_XMLNS  = 'http://purl.org/macgirvin/dfrn/1.0'
   OS_XMLNS    = 'http://ostatus.org/schema/1.0'
+  MTDN_XMLNS  = 'http://mastodon.social/schema/1.0'
 
   def unique_tag(date, id, type)
     "tag:#{Rails.configuration.x.local_domain},#{date.strftime('%Y-%m-%d')}:objectId=#{id}:objectType=#{type}"
@@ -56,6 +60,12 @@ class TagManager
     domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
   end
 
+  def same_acct?(canonical, needle)
+    return true if canonical.casecmp(needle).zero?
+    username, domain = needle.split('@')
+    local_domain?(domain) && canonical.casecmp(username).zero?
+  end
+
   def local_url?(url)
     uri    = Addressable::URI.parse(url)
     domain = uri.host + (uri.port ? ":#{uri.port}" : '')
@@ -78,7 +88,9 @@ class TagManager
 
     case target.object_type
     when :person
-      account_url(target)
+      short_account_url(target)
+    when :note, :comment, :activity
+      short_account_status_url(target.account, target)
     else
       account_stream_entry_url(target.account, target.stream_entry)
     end