diff options
author | Evan Prodromou <evan@status.net> | 2009-09-29 17:25:52 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-09-29 17:25:52 -0400 |
commit | 89ac81c34464b2fc4f54b643d0d95d12bac765ab (patch) | |
tree | 4e3277cb5ad9d93a61262f004a82efc14eaf7d30 /scripts | |
parent | 0a57d1ccee1af8570d4c83934d9ab99fa1a1dc37 (diff) |
remove string-checks from code using Notice::saveNew()
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/maildaemon.php | 9 | ||||
-rwxr-xr-x | scripts/xmppdaemon.php | 11 |
2 files changed, 12 insertions, 8 deletions
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php index 5705cfd50..586bef624 100755 --- a/scripts/maildaemon.php +++ b/scripts/maildaemon.php @@ -260,10 +260,11 @@ class MailerDaemon function add_notice($user, $msg, $fileRecords) { - $notice = Notice::saveNew($user->id, $msg, 'mail'); - if (is_string($notice)) { - $this->log(LOG_ERR, $notice); - return $notice; + try { + $notice = Notice::saveNew($user->id, $msg, 'mail'); + } catch (Exception $e) { + $this->log(LOG_ERR, $e->getMessage()); + return $e->getMessage(); } foreach($fileRecords as $fileRecord){ $this->attachFile($notice, $fileRecord); diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 1b1aec3e6..b2efc07c3 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -323,12 +323,15 @@ class XMPPDaemon extends Daemon mb_strlen($content_shortened))); return; } - $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); - if (is_string($notice)) { - $this->log(LOG_ERR, $notice); - $this->from_site($user->jabber, $notice); + + try { + $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); + } catch (Exception $e) { + $this->log(LOG_ERR, $e->getMessage()); + $this->from_site($user->jabber, $e->getMessage()); return; } + common_broadcast_notice($notice); $this->log(LOG_INFO, 'Added notice ' . $notice->id . ' from user ' . $user->nickname); |