3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Protocol;
24 use Friendica\Protocol\ActivityNamespace;
27 * Base class for the Activity Verbs
32 * Indicates that the actor marked the object as an item of special interest.
34 * @see http://activitystrea.ms/head/activity-schema.html#verbs
37 const LIKE = ActivityNamespace::ACTIVITY_SCHEMA . 'like';
39 * Dislike a message ("I don't like the post")
41 * @see http://purl.org/macgirvin/dfrn/1.0/dislike
44 const DISLIKE = ActivityNamespace::DFRN . '/dislike';
49 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attend
52 const ATTEND = ActivityNamespace::ZOT . '/activity/attendyes';
54 * Don't attend an event
56 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendno
59 const ATTENDNO = ActivityNamespace::ZOT . '/activity/attendno';
61 * Attend maybe an event
63 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendmaybe
66 const ATTENDMAYBE = ActivityNamespace::ZOT . '/activity/attendmaybe';
69 * Indicates the creation of a friendship that is reciprocated by the object.
71 * @see http://activitystrea.ms/head/activity-schema.html#verbs
74 const FRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'make-friend';
76 * Indicates the creation of a friendship that has not yet been reciprocated by the object.
78 * @see http://activitystrea.ms/head/activity-schema.html#verbs
81 const REQ_FRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'request-friend';
83 * Indicates that the actor has removed the object from the collection of friends.
85 * @see http://activitystrea.ms/head/activity-schema.html#verbs
88 const UNFRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'remove-friend';
90 * Indicates that the actor began following the activity of the object.
92 * @see http://activitystrea.ms/head/activity-schema.html#verbs
95 const FOLLOW = ActivityNamespace::ACTIVITY_SCHEMA . 'follow';
97 * Indicates that the actor has stopped following the object.
99 * @see http://activitystrea.ms/head/activity-schema.html#verbs
102 const UNFOLLOW = ActivityNamespace::ACTIVITY_SCHEMA . 'stop-following';
104 * Indicates that the actor has become a member of the object.
106 * @see http://activitystrea.ms/head/activity-schema.html#verbs
109 const JOIN = ActivityNamespace::ACTIVITY_SCHEMA . 'join';
111 * Implementors SHOULD use verbs such as post where the actor is adding new items to a collection or similar.
113 * @see http://activitystrea.ms/head/activity-schema.html#verbs
116 const POST = ActivityNamespace::ACTIVITY_SCHEMA . 'post';
118 * The "update" verb indicates that the actor has modified the object.
120 * @see http://activitystrea.ms/head/activity-schema.html#verbs
123 const UPDATE = ActivityNamespace::ACTIVITY_SCHEMA . 'update';
125 * Indicates that the actor has identified the presence of a target inside another object.
127 * @see http://activitystrea.ms/head/activity-schema.html#verbs
130 const TAG = ActivityNamespace::ACTIVITY_SCHEMA . 'tag';
132 * Indicates that the actor marked the object as an item of special interest.
134 * @see http://activitystrea.ms/head/activity-schema.html#verbs
137 const FAVORITE = ActivityNamespace::ACTIVITY_SCHEMA . 'favorite';
139 * Indicates that the actor has removed the object from the collection of favorited items.
141 * @see http://activitystrea.ms/head/activity-schema.html#verbs
144 const UNFAVORITE = ActivityNamespace::ACTIVITY_SCHEMA . 'unfavorite';
146 * Indicates that the actor has called out the object to readers.
148 * @see http://activitystrea.ms/head/activity-schema.html#verbs
151 const SHARE = ActivityNamespace::ACTIVITY_SCHEMA . 'share';
153 * Indicates that the actor has deleted the object.
155 * @see http://activitystrea.ms/head/activity-schema.html#verbs
158 const DELETE = ActivityNamespace::ACTIVITY_SCHEMA . 'delete';
160 * Indicates that the actor is calling the target's attention the object.
162 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce
165 const ANNOUNCE = ActivityNamespace::ACTIVITY2 . 'Announce';
170 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_poke
173 const POKE = ActivityNamespace::ZOT . '/activity/poke';
176 const O_UNFOLLOW = ActivityNamespace::OSTATUS . '/unfollow';
177 const O_UNFAVOURITE = ActivityNamespace::OSTATUS . '/unfavorite';
180 * likes (etc.) can apply to other things besides posts. Check if they are post children,
181 * in which case we handle them specially
183 * Hidden activities, which doesn't need to be shown
185 const HIDDEN_ACTIVITIES = [
186 Activity::LIKE, Activity::DISLIKE,
187 Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE,
193 * Checks if the given activity is a hidden activity
195 * @param string $activity The current activity
197 * @return bool True, if the activity is hidden
199 public function isHidden(string $activity)
201 foreach (self::HIDDEN_ACTIVITIES as $hiddenActivity) {
202 if ($this->match($activity, $hiddenActivity)) {
211 * Compare activity uri. Knows about activity namespace.
213 * @param string $haystack
214 * @param string $needle
218 public function match(string $haystack, string $needle)
220 return (($haystack === $needle) ||
221 ((basename($needle) === $haystack) &&
222 strstr($needle, ActivityNamespace::ACTIVITY_SCHEMA)));