. */ if (!defined('GNUSOCIAL')) { exit(1); } /** * @package Activity * @maintainer Mikael Nordfeldth */ class ActivityVerbPostModule extends ActivityVerbHandlerModule { const MODULE_VERSION = '2.0.0'; // TODO: Implement a "fallback" feature which can handle anything _as_ an activityobject "note" public function tag() { return 'post'; } public function types() { return array(ActivityObject::ARTICLE, ActivityObject::BLOGENTRY, ActivityObject::NOTE, ActivityObject::STATUS, ActivityObject::COMMENT, // null, // if we want to follow the original Ostatus_profile::processActivity code ); } public function verbs() { return array(ActivityVerb::POST); } // FIXME: Set this to abstract public in classes/modules/ActivityHandlerModule.php when all plugins have migrated! protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array()) { assert($this->isMyActivity($act)); $stored->object_type = ActivityUtils::resolveUri($act->objects[0]->type); if (common_valid_http_url($act->objects[0]->link)) { $stored->url = $act->objects[0]->link; } // We don't have to do just about anything for a new, remote notice since the fields // are handled in the main Notice::saveActivity function. Such as content, attachments, // parent/conversation etc. // By returning true here instead of something that evaluates // to false, we show that we have processed everything properly. return true; } public function activityObjectFromNotice(Notice $notice) { $object = new ActivityObject(); $object->type = $notice->object_type ?: ActivityObject::NOTE; $object->id = $notice->getUri(); $object->title = sprintf('New %1$s by %2$s', ActivityObject::canonicalType($object->type), $notice->getProfile()->getNickname()); $object->content = $notice->getRendered(); $object->link = $notice->getUrl(); $object->extra[] = array('statusnet:notice_id', null, $notice->getID()); return $object; } public function deleteRelated(Notice $notice) { // No action needed as the table for data storage _is_ the notice table. return true; } /** * Command stuff */ // FIXME: Move stuff from lib/command.php to here just as with Share etc. /** * Layout stuff */ protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null) { $out->raw($stored->getRendered()); } protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped) { // return page title } protected function doActionPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped) { // prepare Action? } protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped) { // handle POST } protected function getActivityForm(ManagedAction $action, $verb, Notice $target, Profile $scoped) { return new NoticeForm($action, array()); } public function onModuleVersion(array &$versions): bool { $versions[] = array('name' => 'Post verb', 'version' => self::MODULE_VERSION, 'author' => 'Mikael Nordfeldth', 'homepage' => GNUSOCIAL_ENGINE_URL, 'rawdescription' => // TRANS: Module description. _m('Post handling with ActivityStreams.')); return true; } }