3 namespace Friendica\Protocol;
5 use Friendica\Protocol\ActivityNamespace;
8 * Base class for the Activity Verbs
13 * Indicates that the actor marked the object as an item of special interest.
15 * @see http://activitystrea.ms/head/activity-schema.html#verbs
18 const LIKE = ActivityNamespace::ACTIVITY_SCHEMA . 'like';
20 * Dislike a message ("I don't like the post")
22 * @see http://purl.org/macgirvin/dfrn/1.0/dislike
25 const DISLIKE = ActivityNamespace::DFRN . '/dislike';
30 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attend
33 const ATTEND = ActivityNamespace::ZOT . '/activity/attendyes';
35 * Don't attend an event
37 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendno
40 const ATTENDNO = ActivityNamespace::ZOT . '/activity/attendno';
42 * Attend maybe an event
44 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendmaybe
47 const ATTENDMAYBE = ActivityNamespace::ZOT . '/activity/attendmaybe';
50 * Indicates the creation of a friendship that is reciprocated by the object.
52 * @see http://activitystrea.ms/head/activity-schema.html#verbs
55 const FRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'make-friend';
57 * Indicates the creation of a friendship that has not yet been reciprocated by the object.
59 * @see http://activitystrea.ms/head/activity-schema.html#verbs
62 const REQ_FRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'request-friend';
64 * Indicates that the actor has removed the object from the collection of friends.
66 * @see http://activitystrea.ms/head/activity-schema.html#verbs
69 const UNFRIEND = ActivityNamespace::ACTIVITY_SCHEMA . 'remove-friend';
71 * Indicates that the actor began following the activity of the object.
73 * @see http://activitystrea.ms/head/activity-schema.html#verbs
76 const FOLLOW = ActivityNamespace::ACTIVITY_SCHEMA . 'follow';
78 * Indicates that the actor has stopped following the object.
80 * @see http://activitystrea.ms/head/activity-schema.html#verbs
83 const UNFOLLOW = ActivityNamespace::ACTIVITY_SCHEMA . 'stop-following';
85 * Indicates that the actor has become a member of the object.
87 * @see http://activitystrea.ms/head/activity-schema.html#verbs
90 const JOIN = ActivityNamespace::ACTIVITY_SCHEMA . 'join';
92 * Implementors SHOULD use verbs such as post where the actor is adding new items to a collection or similar.
94 * @see http://activitystrea.ms/head/activity-schema.html#verbs
97 const POST = ActivityNamespace::ACTIVITY_SCHEMA . 'post';
99 * The "update" verb indicates that the actor has modified the object.
101 * @see http://activitystrea.ms/head/activity-schema.html#verbs
104 const UPDATE = ActivityNamespace::ACTIVITY_SCHEMA . 'update';
106 * Indicates that the actor has identified the presence of a target inside another object.
108 * @see http://activitystrea.ms/head/activity-schema.html#verbs
111 const TAG = ActivityNamespace::ACTIVITY_SCHEMA . 'tag';
113 * Indicates that the actor marked the object as an item of special interest.
115 * @see http://activitystrea.ms/head/activity-schema.html#verbs
118 const FAVORITE = ActivityNamespace::ACTIVITY_SCHEMA . 'favorite';
120 * Indicates that the actor has removed the object from the collection of favorited items.
122 * @see http://activitystrea.ms/head/activity-schema.html#verbs
125 const UNFAVORITE = ActivityNamespace::ACTIVITY_SCHEMA . 'unfavorite';
127 * Indicates that the actor has called out the object to readers.
129 * @see http://activitystrea.ms/head/activity-schema.html#verbs
132 const SHARE = ActivityNamespace::ACTIVITY_SCHEMA . 'share';
134 * Indicates that the actor has deleted the object.
136 * @see http://activitystrea.ms/head/activity-schema.html#verbs
139 const DELETE = ActivityNamespace::ACTIVITY_SCHEMA . 'delete';
141 * Indicates that the actor is calling the target's attention the object.
143 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce
146 const ANNOUNCE = ActivityNamespace::ACTIVITY2 . 'Announce';
151 * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_poke
154 const POKE = ActivityNamespace::ZOT . '/activity/poke';
157 const O_UNFOLLOW = ActivityNamespace::OSTATUS . '/unfollow';
158 const O_UNFAVOURITE = ActivityNamespace::OSTATUS . '/unfavorite';
161 * likes (etc.) can apply to other things besides posts. Check if they are post children,
162 * in which case we handle them specially
164 * Hidden activities, which doesn't need to be shown
166 const HIDDEN_ACTIVITIES = [
167 Activity::LIKE, Activity::DISLIKE,
168 Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE,
174 * Checks if the given activity is a hidden activity
176 * @param string $activity The current activity
178 * @return bool True, if the activity is hidden
180 public function isHidden(string $activity)
182 foreach (self::HIDDEN_ACTIVITIES as $hiddenActivity) {
183 if ($this->match($activity, $hiddenActivity)) {
192 * Compare activity uri. Knows about activity namespace.
194 * @param string $haystack
195 * @param string $needle
199 public function match(string $haystack, string $needle)
201 return (($haystack === $needle) ||
202 ((basename($needle) === $haystack) &&
203 strstr($needle, ActivityNamespace::ACTIVITY_SCHEMA)));