X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fxmppdaemon.php;h=e52e2a6afe6d3fdcb6293a2f340b00dd86102739;hb=cc662ec1e6185c48fdd78aeef5aaa73c5da06293;hp=9e621e725a3fae3697c22cce4e8e8373607e65df;hpb=4737563b957e84ee06d07f373af533b2f037497a;p=quix0rs-gnu-social.git diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 9e621e725a..e52e2a6afe 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -187,7 +187,7 @@ class XMPPDaemon extends Daemon return; } if ($this->handle_command($user, $pl['body'])) { - $this->log(LOG_INFO, "Command messag by $from handled."); + $this->log(LOG_INFO, "Command message by $from handled."); return; } else if ($this->is_autoreply($pl['body'])) { $this->log(LOG_INFO, 'Ignoring auto reply from ' . $from); @@ -316,17 +316,22 @@ class XMPPDaemon extends Daemon { $body = trim($pl['body']); $content_shortened = common_shorten_links($body); - if (mb_strlen($content_shortened) > 140) { + if (Notice::contentTooLong($content_shortened)) { $from = jabber_normalize_jid($pl['from']); - $this->from_site($from, "Message too long - maximum is 140 characters, you sent ".mb_strlen($content_shortened)); + $this->from_site($from, sprintf(_("Message too long - maximum is %d characters, you sent %d"), + Notice::maxContent(), + 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);