]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
common_find_attentions to populate activities from content text
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 7 Jan 2016 22:23:37 +0000 (23:23 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 7 Jan 2016 22:23:37 +0000 (23:23 +0100)
lib/util.php

index 30ad757f75fcb2f1f9fffb86a62f62f169c91d9d..62cd13af4a4231339c2b1b66e6be04616fcd5f10 100644 (file)
@@ -681,6 +681,18 @@ function common_linkify_mention(array $mention)
     return $output;
 }
 
+function common_find_attentions($text, Profile $sender, Notice $parent=null)
+{
+    $mentions = common_find_mentions($text, $sender, $parent);
+    $atts = array();
+    foreach ($mentions as $mention) {
+        foreach ($mention['mentioned'] as $mentioned) {
+            $atts[$mentioned->getUri()] = $mentioned->isGroup() ? ActivityObject::GROUP : ActivityObject::PERSON;
+        }
+    }
+    return $atts;
+}
+
 /**
  * Find @-mentions in the given text, using the given notice object as context.
  * References will be resolved with common_relative_profile() against the user