if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/lib/settingsaction.php');
+require_once(INSTALLDIR.'/lib/jabber.php');
class ImsettingsAction extends SettingsAction {
if (!defined('LACONICA')) { exit(1); }
+require_once('xmpp.php');
+
function jabber_valid_base_jid($jid) {
# Cheap but effective
return Validate::email($jid);
jabber_send_message($address, $body);
}
+
+function jabber_broadcast_notice($notice) {
+ # First, get users subscribed to this profile
+ # XXX: use a join here rather than looping through results
+ $profile = Profile::staticGet($notice->profile_id);
+ if (!$profile) {
+ common_log(LOG_WARNING, 'Refusing to broadcast notice with ' .
+ 'unknown profile ' . common_log_objstring($notice),
+ __FILE__);
+ return false;
+ }
+ $sub = new Subscription();
+ $sub->subscribed = $notice->profile_id;
+ if ($sub->find()) {
+ $msg = jabber_format_notice($profile, $notice);
+ while ($sub->fetch()) {
+ $user = User::staticGet($sub->subscriber);
+ if ($user && $user->jabber) {
+ jabber_send_message($user->jabber,
+ $msg);
+ }
+ }
+ }
+}
+function jabber_format_notice(&$profile, &$notice) {
+ return = $profile->nickname . ': ' . $notice->content;
+}
require_once(INSTALLDIR.'/lib/omb.php');
omb_broadcast_remote_subscribers($notice);
}
- // XXX: broadcast notices to Jabber
+ require_once(INSTALLDIR.'/lib/jabber.php');
+ jabber_broadcast_notice($notice);
// XXX: broadcast notices to SMS
// XXX: broadcast notices to other IM
return true;