]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Activity.php
database.sql updated, standards fixed
[friendica.git] / src / Protocol / Activity.php
index ddbfce1b7315db01fdcfbe353f2cf23a00563deb..0f15e851c3df8ee3a5ec7900bcceffb27f68d040 100644 (file)
 <?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Protocol;
 
-use Friendica\Protocol\Activity\Namespaces;
+use Friendica\Protocol\ActivityNamespace;
 
 /**
- * Base class for the Activity constants and match method
+ * Base class for the Activity Verbs
  */
 final class Activity
 {
-       const LIKE         = Namespaces::ACTIVITY_SCHEMA . 'like';
+       /**
+        * Indicates that the actor marked the object as an item of special interest.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const LIKE = ActivityNamespace::ACTIVITY_SCHEMA . 'like';
+       /**
+        * Dislike a message ("I don't like the post")
+        *
+        * @see http://purl.org/macgirvin/dfrn/1.0/dislike
+        * @var string
+        */
+       const DISLIKE = ActivityNamespace::DFRN . '/dislike';
+
+       /**
+        * Attend an event
+        *
+        * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attend
+        * @var string
+        */
+       const ATTEND      = ActivityNamespace::ZOT . '/activity/attendyes';
+       /**
+        * Don't attend an event
+        *
+        * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendno
+        * @var string
+        */
+       const ATTENDNO    = ActivityNamespace::ZOT . '/activity/attendno';
+       /**
+        * Attend maybe an event
+        *
+        * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendmaybe
+        * @var string
+        */
+       const ATTENDMAYBE = ActivityNamespace::ZOT . '/activity/attendmaybe';
+
+       /**
+        * Indicates the creation of a friendship that is reciprocated by the object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const FRIEND      = ActivityNamespace::ACTIVITY_SCHEMA . 'make-friend';
+       /**
+        * Indicates the creation of a friendship that has not yet been reciprocated by the object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const REQ_FRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'request-friend';
+       /**
+        * Indicates that the actor has removed the object from the collection of friends.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const UNFRIEND   = ActivityNamespace::ACTIVITY_SCHEMA . 'remove-friend';
+       /**
+        * Indicates that the actor began following the activity of the object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const FOLLOW     = ActivityNamespace::ACTIVITY_SCHEMA . 'follow';
+       /**
+        * Indicates that the actor has stopped following the object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const UNFOLLOW   = ActivityNamespace::ACTIVITY_SCHEMA . 'stop-following';
+       /**
+        * Indicates that the actor has become a member of the object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const JOIN       = ActivityNamespace::ACTIVITY_SCHEMA . 'join';
+       /**
+        * Implementors SHOULD use verbs such as post where the actor is adding new items to a collection or similar.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const POST       = ActivityNamespace::ACTIVITY_SCHEMA . 'post';
+       /**
+        * The "update" verb indicates that the actor has modified the object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const UPDATE     = ActivityNamespace::ACTIVITY_SCHEMA . 'update';
+       /**
+        * Indicates that the actor has identified the presence of a target inside another object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const TAG        = ActivityNamespace::ACTIVITY_SCHEMA . 'tag';
+       /**
+        * Indicates that the actor marked the object as an item of special interest.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const FAVORITE   = ActivityNamespace::ACTIVITY_SCHEMA . 'favorite';
+       /**
+        * Indicates that the actor has removed the object from the collection of favorited items.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const UNFAVORITE = ActivityNamespace::ACTIVITY_SCHEMA . 'unfavorite';
+       /**
+        * Indicates that the actor has called out the object to readers.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const SHARE      = ActivityNamespace::ACTIVITY_SCHEMA . 'share';
+       /**
+        * Indicates that the actor has deleted the object.
+        *
+        * @see http://activitystrea.ms/head/activity-schema.html#verbs
+        * @var string
+        */
+       const DELETE     = ActivityNamespace::ACTIVITY_SCHEMA . 'delete';
+       /**
+        * Indicates that the actor is calling the target's attention the object.
+        *
+        * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce
+        * @var string
+        */
+       const ANNOUNCE   = ActivityNamespace::ACTIVITY2 . 'Announce';
 
-       const DISLIKE      = Namespaces::DFRN            . '/dislike';
-       const ATTEND       = Namespaces::ZOT             . '/activity/attendyes';
-       const ATTENDNO     = Namespaces::ZOT             . '/activity/attendno';
-       const ATTENDMAYBE  = Namespaces::ZOT             . '/activity/attendmaybe';
-       const OBJ_HEART    = Namespaces::DFRN            . '/heart';
+       /**
+        * Pokes an user.
+        *
+        * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_poke
+        * @var string
+        */
+       const POKE       = ActivityNamespace::ZOT . '/activity/poke';
 
-       const FRIEND       = Namespaces::ACTIVITY_SCHEMA . 'make-friend';
-       const REQ_FRIEND   = Namespaces::ACTIVITY_SCHEMA . 'request-friend';
-       const UNFRIEND     = Namespaces::ACTIVITY_SCHEMA . 'remove-friend';
-       const FOLLOW       = Namespaces::ACTIVITY_SCHEMA . 'follow';
-       const UNFOLLOW     = Namespaces::ACTIVITY_SCHEMA . 'stop-following';
-       const JOIN         = Namespaces::ACTIVITY_SCHEMA . 'join';
-       const POST         = Namespaces::ACTIVITY_SCHEMA . 'post';
-       const UPDATE       = Namespaces::ACTIVITY_SCHEMA . 'update';
-       const TAG          = Namespaces::ACTIVITY_SCHEMA . 'tag';
-       const FAVORITE     = Namespaces::ACTIVITY_SCHEMA . 'favorite';
-       const UNFAVORITE   = Namespaces::ACTIVITY_SCHEMA . 'unfavorite';
-       const SHARE        = Namespaces::ACTIVITY_SCHEMA . 'share';
-       const DELETE       = Namespaces::ACTIVITY_SCHEMA . 'delete';
-       const ANNOUNCE     = Namespaces::ACTIVITY2       . 'Announce';
 
-       const POKE         = Namespaces::ZOT             . '/activity/poke';
+       const O_UNFOLLOW    = ActivityNamespace::OSTATUS . '/unfollow';
+       const O_UNFAVOURITE = ActivityNamespace::OSTATUS . '/unfavorite';
 
-       const OBJ_BOOKMARK = Namespaces::ACTIVITY_SCHEMA . 'bookmark';
-       const OBJ_COMMENT  = Namespaces::ACTIVITY_SCHEMA . 'comment';
-       const OBJ_NOTE     = Namespaces::ACTIVITY_SCHEMA . 'note';
-       const OBJ_PERSON   = Namespaces::ACTIVITY_SCHEMA . 'person';
-       const OBJ_IMAGE    = Namespaces::ACTIVITY_SCHEMA . 'image';
-       const OBJ_PHOTO    = Namespaces::ACTIVITY_SCHEMA . 'photo';
-       const OBJ_VIDEO    = Namespaces::ACTIVITY_SCHEMA . 'video';
-       const OBJ_P_PHOTO  = Namespaces::ACTIVITY_SCHEMA . 'profile-photo';
-       const OBJ_ALBUM    = Namespaces::ACTIVITY_SCHEMA . 'photo-album';
-       const OBJ_EVENT    = Namespaces::ACTIVITY_SCHEMA . 'event';
-       const OBJ_GROUP    = Namespaces::ACTIVITY_SCHEMA . 'group';
-       const OBJ_TAGTERM  = Namespaces::DFRN            . '/tagterm';
-       const OBJ_PROFILE  = Namespaces::DFRN            . '/profile';
+       /**
+        * React to a post via an emoji 
+        *
+        * @var string
+        */
+       const EMOJIREACT = ActivityNamespace::LITEPUB . '/emojireact';
 
-       const OBJ_QUESTION = 'http://activityschema.org/object/question';
+       /**
+        * View notification from Peertube
+        *
+        * @var string
+        */
+       const VIEW       = ActivityNamespace::PEERTUBE . '/view';
 
        /**
         * likes (etc.) can apply to other things besides posts. Check if they are post children,
@@ -57,10 +197,12 @@ final class Activity
         * Hidden activities, which doesn't need to be shown
         */
        const HIDDEN_ACTIVITIES = [
-               Activity::LIKE, Activity::DISLIKE,
-               Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE,
-               Activity::FOLLOW,
-               Activity::ANNOUNCE,
+               self::LIKE, self::DISLIKE,
+               self::ATTEND, self::ATTENDNO, self::ATTENDMAYBE,
+               self::FOLLOW,
+               self::ANNOUNCE,
+               self::EMOJIREACT,
+               self::VIEW,
        ];
 
        /**
@@ -70,7 +212,7 @@ final class Activity
         *
         * @return bool True, if the activity is hidden
         */
-       public function isHidden(string $activity)
+       public function isHidden(string $activity): bool
        {
                foreach (self::HIDDEN_ACTIVITIES as $hiddenActivity) {
                        if ($this->match($activity, $hiddenActivity)) {
@@ -89,10 +231,10 @@ final class Activity
         *
         * @return boolean
         */
-       public function match(string $haystack, string $needle)
+       public function match(string $haystack, string $needle): bool
        {
                return (($haystack === $needle) ||
                        ((basename($needle) === $haystack) &&
-                        strstr($needle, Namespaces::ACTIVITY_SCHEMA)));
+                        strstr($needle, ActivityNamespace::ACTIVITY_SCHEMA)));
        }
 }