diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-07-29 22:28:56 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-07-29 22:28:56 -0400 |
commit | d79dc8344b529281dfb8a8383c529720a429472b (patch) | |
tree | 33d4914a14e62b657a426520a5844340c187059b /maildaemon.php | |
parent | 44fb662efb0e664287863dfe106f332a83a2f622 (diff) |
refactor notice-adding code to one static method on Notice
darcs-hash:20080730022856-84dde-f19e4ff5d5ae2603b63b8aebd8f878ec90b3ce22.gz
Diffstat (limited to 'maildaemon.php')
-rwxr-xr-x | maildaemon.php | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/maildaemon.php b/maildaemon.php index f8fd7c11a..5be62efb8 100755 --- a/maildaemon.php +++ b/maildaemon.php @@ -115,35 +115,11 @@ class MailerDaemon { } function add_notice($user, $msg) { - $notice = new Notice(); - $notice->is_local = 1; - $notice->profile_id = $user->id; - $notice->content = trim(substr($msg, 0, 140)); - $notice->rendered = common_render_content($notice->content, $notice); - $notice->created = DB_DataObject_Cast::dateTime(); - $notice->query('BEGIN'); - $id = $notice->insert(); - if (!$id) { - $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); - $this->log(LOG_ERR, - 'Could not insert ' . common_log_objstring($notice) . - ' for user ' . common_log_objstring($user) . - ': ' . $last_error->message); + $notice = Notice::saveNew($user->id, $msg, 'mail'); + if (is_string($notice)) { + $this->log(LOG_ERR, $notice); return; } - $orig = clone($notice); - $notice->uri = common_notice_uri($notice); - $result = $notice->update($orig); - if (!$result) { - $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); - $this->log(LOG_ERR, - 'Could not add URI to ' . common_log_objstring($notice) . - ' for user ' . common_log_objstring($user) . - ': ' . $last_error->message); - return; - } - $notice->query('COMMIT'); - common_save_replies($notice); common_broadcast_notice($notice); $this->log(LOG_INFO, 'Added notice ' . $notice->id . ' from user ' . $user->nickname); |