summaryrefslogtreecommitdiff
path: root/xmppdaemon.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-29 22:28:56 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-29 22:28:56 -0400
commitd79dc8344b529281dfb8a8383c529720a429472b (patch)
tree33d4914a14e62b657a426520a5844340c187059b /xmppdaemon.php
parent44fb662efb0e664287863dfe106f332a83a2f622 (diff)
refactor notice-adding code to one static method on Notice
darcs-hash:20080730022856-84dde-f19e4ff5d5ae2603b63b8aebd8f878ec90b3ce22.gz
Diffstat (limited to 'xmppdaemon.php')
-rwxr-xr-xxmppdaemon.php31
1 files changed, 3 insertions, 28 deletions
diff --git a/xmppdaemon.php b/xmppdaemon.php
index d9b706454..7977dc804 100755
--- a/xmppdaemon.php
+++ b/xmppdaemon.php
@@ -223,36 +223,11 @@ class XMPPDaemon {
}
function add_notice(&$user, &$pl) {
- $notice = new Notice();
- $notice->is_local = 1;
- $notice->profile_id = $user->id;
- $notice->content = trim(substr($pl['body'], 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);
- 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);
+ $notice = Notice::saveNew($user->id, trim(substr($pl['body'], 0, 140)), 'xmpp');
+ if (is_string($notice)) {
+ $this->log(LOG_ERR, $notice);
return;
}
- $notice->query('COMMIT');
- common_save_replies($notice);
- $notice->saveTags();
common_real_broadcast($notice);
$this->log(LOG_INFO,
'Added notice ' . $notice->id . ' from user ' . $user->nickname);