+ // Save per-notice metadata...
+
+ if (isset($replies)) {
+ $notice->saveKnownReplies($replies);
+ } else {
+ $notice->saveReplies();
+ }
+
+ if (isset($tags)) {
+ $notice->saveKnownTags($tags);
+ } else {
+ $notice->saveTags();
+ }
+
+ // Note: groups may save tags, so must be run after tags are saved
+ // to avoid errors on duplicates.
+ // Note: groups should always be set.
+
+ $notice->saveKnownGroups($groups);
+
+ if (isset($urls)) {
+ $notice->saveKnownUrls($urls);
+ } else {
+ $notice->saveUrls();
+ }
+
+ if ($distribute) {
+ // Prepare inbox delivery, may be queued to background.
+ $notice->distribute();
+ }
+
+ return $notice;
+ }
+
+ static function saveActivity(Activity $act, Profile $actor, array $options=array())
+ {
+ // First check if we're going to let this Activity through from the specific actor
+ if (!$actor->hasRight(Right::NEWNOTICE)) {
+ common_log(LOG_WARNING, "Attempted post from user disallowed to post: " . $actor->getNickname());
+
+ // TRANS: Client exception thrown when a user tries to post while being banned.
+ throw new ClientException(_m('You are banned from posting notices on this site.'), 403);
+ }
+ if (common_config('throttle', 'enabled') && !self::checkEditThrottle($actor->id)) {
+ common_log(LOG_WARNING, 'Excessive posting by profile #' . $actor->id . '; throttled.');
+ // TRANS: Client exception thrown when a user tries to post too many notices in a given time frame.
+ throw new ClientException(_m('Too many notices too fast; take a breather '.
+ 'and post again in a few minutes.'));
+ }
+
+ // Get ActivityObject properties
+ if (!empty($act->id)) {
+ // implied object
+ $options['uri'] = $act->id;
+ $options['url'] = $act->link;
+ } else {
+ $actobj = count($act->objects)==1 ? $act->objects[0] : null;
+ if (!is_null($actobj) && !empty($actobj->id)) {
+ $options['uri'] = $actobj->id;
+ if ($actobj->link) {
+ $options['url'] = $actobj->link;
+ } elseif (preg_match('!^https?://!', $actobj->id)) {
+ $options['url'] = $actobj->id;