}
}
- if (empty($notice->conversation)) {
- $conv = Conversation::create();
- $notice->conversation = $conv->id;
- common_log(LOG_INFO, "No known conversation for status {$statusId} so making a new one {$conv->id}.");
- }
-
$notice->is_local = Notice::GATEWAY;
$notice->content = html_entity_decode($this->linkify($status, FALSE), ENT_QUOTES, 'UTF-8');
$id = $notice->insert();
- if (!$id) {
+ if ($id === false) {
common_log_db_error($notice, 'INSERT', __FILE__);
common_log(LOG_ERR, __METHOD__ . ' - Problem saving notice.');
}
+ if (empty($notice->conversation)) {
+ $orig = clone($notice);
+ $conv = Conversation::create($notice);
+ common_log(LOG_INFO, "No known conversation for status {$statusId} so a new one ({$conv->id}) was created.");
+ $notice->conversation = $conv->id;
+ $notice->update($orig);
+ }
+
Event::handle('EndNoticeSave', array($notice));
}
return false;
}
- // check for remote profile
- $remote_pro = Remote_profile::getKV('uri', $profileurl);
-
- if (!($remote_pro instanceof Remote_profile)) {
- $remote_pro = new Remote_profile();
- $remote_pro->id = $id;
- $remote_pro->uri = $profileurl;
- $remote_pro->created = common_sql_now();
-
- try {
- $rid = $remote_pro->insert();
- if (empty($rid)) {
- throw new Exception('Failed insert');
- }
- } catch (Exception $e) {
- common_log(LOG_WARNING, __METHOD__ . " Couldn't save remote profile: " . $e->getMessage());
- common_log_db_error($profile, 'INSERT', __FILE__);
- $profile->query("ROLLBACK");
- return false;
- }
- }
-
$profile->query("COMMIT");
$this->updateAvatar($twuser, $profile);
return $profile;
common_debug(__METHOD__ . " - Updating profile avatar (profile_id={$profile->id}) " .
"from {$avatar->filename} to {$filename}");
// else we continue with creating a new avatar
- } catch (Exception $e) {
- // Avatar was not found. We can catch NoResultException or FileNotFoundException
+ } catch (NoAvatarException $e) {
+ // Avatar was not found. We can catch NoAvatarException or FileNotFoundException
// but generally we just want to continue creating a new avatar.
common_debug(__METHOD__ . " - No avatar found for (profile_id={$profile->id})");
}
static function tagLink($tag, $orig)
{
- return "<a href='https://search.twitter.com/search?q=%23{$tag}' class='hashtag'>{$orig}</a>";
+ return "<a href='https://twitter.com/search?q=%23{$tag}' class='hashtag'>{$orig}</a>";
}
static function atLink($screenName, $fullName, $orig)
if (common_config('attachments', 'process_links')) {
if (!empty($status->entities) && !empty($status->entities->urls)) {
foreach ($status->entities->urls as $url) {
- File::processNew($url->url, $notice->id);
+ try {
+ File::processNew($url->url, $notice->id);
+ } catch (ServerException $e) {
+ // Could not process attached URL
+ }
}
}
}