public static function addNew(Notice $notice, Profile $actor = null) { if (is_null($actor)) { $actor = $notice->getProfile(); } if ($notice->getProfile()->hasRole(Profile_role::DELETED)) { // Don't emit notices if the notice author is (being) deleted return false; } $act = new Activity(); $act->verb = ActivityVerb::DELETE; $act->time = time(); $act->id = $notice->getUri(); $act->content = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'), htmlspecialchars($actor->getUrl()), htmlspecialchars($actor->getBestName()), htmlspecialchars($notice->getUrl()), htmlspecialchars($notice->getUri())); $act->actor = $actor->asActivityObject(); $act->target = new ActivityObject(); // We don't save the notice object, as it's supposed to be removed! $act->target->id = $notice->getUri(); $act->target->type = $notice->getObjectType(); $act->objects = array(clone $act->target); $url = $notice->getUrl(); $act->selfLink = $url; $act->editLink = $url; // This will make ActivityModeration run saveObjectFromActivity which adds // a new Deleted_notice entry in the database as well as deletes the notice // if the actor has permission to do so. $stored = Notice::saveActivity($act, $actor); return $stored; }
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('status_net', array('notice_id' => $notice->getID())); return $object; }
function activityObjectFromNotice(Notice $notice) { $object = new ActivityObject(); $object->id = $notice->uri; $object->type = Video::OBJECT_TYPE; $object->title = $notice->content; $object->summary = $notice->content; $object->link = $notice->getUrl(); $vid = Video::getByNotice($notice); if ($vid) { $object->extra[] = array('link', array('rel' => 'enclosure', 'href' => $vid->url), array()); } return $object; }
function activityObjectFromNoticePoll(Notice $notice) { $object = new ActivityObject(); $object->id = $notice->uri; $object->type = self::POLL_OBJECT; $object->title = $notice->content; $object->summary = $notice->content; $object->link = $notice->getUrl(); $poll = Poll::getByNotice($notice); if ($poll) { // Stash data to be formatted later by // $this->activityObjectOutputAtom() or // $this->activityObjectOutputJson()... $object->pollQuestion = $poll->question; $object->pollOptions = $poll->getOptions(); } return $object; }
/** * Mirror a notice by emitting a new notice with the same contents. * Kind of dirty, but if pulling an external data feed into an account * that may be what you want. * * @param Notice $notice * @return mixed Notice on successful repeat, true if already repeated, false on failure */ protected function copyNotice($profile, $notice) { $options = array('is_local' => Notice::LOCAL_PUBLIC, 'url' => $notice->getUrl(), 'rendered' => $notice->getRendered()); $saved = Notice::saveNew($profile->id, $notice->content, 'feed', $options); return $saved; }
/** * Notify remote users when their notices get de-favorited. * * @param Profile $profile Profile person doing the de-faving * @param Notice $notice Notice being favored * * @return hook return value */ function onEndDisfavorNotice(Profile $profile, Notice $notice) { // Only distribute local users' disfavor actions, remote users // will have already distributed theirs. if (!$profile->isLocal()) { return true; } $oprofile = Ostatus_profile::getKV('profile_id', $notice->profile_id); if (!$oprofile instanceof Ostatus_profile) { return true; } $act = new Activity(); $act->verb = ActivityVerb::UNFAVORITE; $act->id = TagURI::mint('disfavor:%d:%d:%s', $profile->id, $notice->id, common_date_iso8601(time())); $act->time = time(); // TRANS: Title for unliking a remote notice. $act->title = _m('Unlike'); // TRANS: Success message for remove a favorite notice through OStatus. // TRANS: %1$s is the unfavoring user's name, %2$s is URI to the no longer favored notice. $act->content = sprintf(_m('%1$s no longer likes %2$s.'), $profile->getBestName(), $notice->getUrl()); $act->actor = $profile->asActivityObject(); $act->object = $notice->asActivityObject(); $oprofile->notifyActivity($act, $profile); return true; }