3 * GNU Social - a federating social network
4 * Copyright (C) 2014, Free Software Foundation, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('GNUSOCIAL')) { exit(1); }
24 * @maintainer Mikael Nordfeldth <mmn@hethane.se>
26 class ActivityVerbPostPlugin extends ActivityVerbHandlerPlugin
33 public function types()
35 return array(ActivityObject::ARTICLE,
36 ActivityObject::BLOGENTRY,
38 ActivityObject::STATUS,
39 ActivityObject::COMMENT,
40 // null, // if we want to follow the original Ostatus_profile::processActivity code
44 public function verbs()
46 return array(ActivityVerb::POST);
49 // FIXME: Set this to abstract public in lib/activityhandlerplugin.php when all plugins have migrated!
50 protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array())
52 assert($this->isMyActivity($act));
54 $stored->object_type = ActivityUtils::resolveUri($act->objects[0]->type);
56 // We don't have to do just about anything for a new, remote notice since the fields
57 // are handled in the main Notice::saveActivity function. Such as content, attachments,
58 // parent/conversation etc.
60 // By returning true here instead of something that evaluates
61 // to false, we show that we have processed everything properly.
65 public function activityObjectFromNotice(Notice $notice)
67 $object = new ActivityObject();
69 $object->type = $notice->object_type ?: ActivityObject::NOTE;
70 $object->id = $notice->getUri();
71 $object->title = sprintf('New %1$s by %2$s', ActivityObject::canonicalType($object->type), $notice->getProfile()->getNickname());
72 $object->content = $notice->rendered;
73 $object->link = $notice->getUrl();
75 $object->extra[] = array('status_net', array('notice_id' => $notice->getID()));
80 public function deleteRelated(Notice $notice)
82 // No action needed as the table for data storage _is_ the notice table.
91 // FIXME: Move stuff from lib/command.php to here just as with Share etc.
98 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
100 $out->raw($stored->rendered);
103 protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped)
108 protected function doActionPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped)
113 protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
115 // handle repeat POST
118 protected function getActivityForm(ManagedAction $action, $verb, Notice $target, Profile $scoped)
120 return new NoticeForm($action, array());
123 public function onPluginVersion(array &$versions)
125 $versions[] = array('name' => 'Post verb',
126 'version' => GNUSOCIAL_VERSION,
127 'author' => 'Mikael Nordfeldth',
128 'homepage' => 'https://gnu.io/',
130 // TRANS: Plugin description.
131 _m('Post handling with ActivityStreams.'));