+ if (empty($notice->conversation)) {
+ $conv = Conversation::create();
+ $notice->conversation = $conv->id;
+ common_log(LOG_INFO, "No known conversation for status {$status->id} so making a new one {$conv->id}.");
+ }
+
+ $notice->is_local = Notice::GATEWAY;
+
+ $notice->content = common_shorten_links($status->text);
+ $notice->rendered = common_render_content(
+ $notice->content,
+ $notice
+ );
+
+ if (Event::handle('StartNoticeSave', array(&$notice))) {
+
+ $id = $notice->insert();
+
+ if (!$id) {
+ common_log_db_error($notice, 'INSERT', __FILE__);
+ common_log(LOG_ERR, $this->name() .
+ ' - Problem saving notice.');
+ }
+
+ Event::handle('EndNoticeSave', array($notice));
+ }
+
+ Notice_to_status::saveNew($notice->id, $status->id);
+ $notice->blowOnInsert();
+
+ return $notice;
+ }
+
+ /**
+ * Make an URI for a status.
+ *
+ * @param object $status status object
+ *
+ * @return string URI
+ */
+
+ function makeStatusURI($username, $id)
+ {
+ return 'http://twitter.com/'
+ . $username
+ . '/status/'
+ . $id;
+ }
+
+ /**
+ * Look up a Profile by profileurl field. Profile::staticGet() was
+ * not working consistently.
+ *
+ * @param string $nickname local nickname of the Twitter user
+ * @param string $profileurl the profile url
+ *
+ * @return mixed value the first Profile with that url, or null
+ */
+
+ function getProfileByUrl($nickname, $profileurl)
+ {
+ $profile = new Profile();
+ $profile->nickname = $nickname;
+ $profile->profileurl = $profileurl;
+ $profile->limit(1);
+
+ if ($profile->find()) {
+ $profile->fetch();
+ return $profile;
+ }
+
+ return null;
+ }