]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
replies from people you're not subscribed to over Jabber
authorEvan Prodromou <evan@prodromou.name>
Tue, 15 Jul 2008 19:55:13 +0000 (15:55 -0400)
committerEvan Prodromou <evan@prodromou.name>
Tue, 15 Jul 2008 19:55:13 +0000 (15:55 -0400)
darcs-hash:20080715195513-84dde-454419c971015be385d9c4c35f7acbee419031f9.gz

19 files changed:
actions/imsettings.php
classes/Avatar.php
classes/Confirm_address.php
classes/Consumer.php
classes/Nonce.php
classes/Notice.php
classes/Profile.php
classes/Queue_item.php
classes/Remember_me.php
classes/Remote_profile.php
classes/Reply.php
classes/Sms_carrier.php
classes/Subscription.php
classes/Token.php
classes/User.php
classes/User_openid.php
classes/stoica.ini
db/laconica.sql
lib/jabber.php

index f85d9f887b98e3b5d1ecb7d1650d002f5ff70cd1..9e483d06326d6d46cd9115b3a100d27db33c4c52 100644 (file)
@@ -73,6 +73,9 @@ class ImsettingsAction extends SettingsAction {
                common_checkbox('updatefrompresence',
                                _('Post a notice when my Jabber/GTalk status changes.'),
                                $user->updatefrompresence);
+               common_checkbox('jabberreplies',
+                               _('Send me replies through Jabber/GTalk from people I\'m not subscribed to.'),
+                               $user->jabberreplies);
                common_submit('save', _('Save'));
 
                common_element_end('form');
@@ -110,6 +113,7 @@ class ImsettingsAction extends SettingsAction {
 
                $jabbernotify = $this->boolean('jabbernotify');
                $updatefrompresence = $this->boolean('updatefrompresence');
+               $jabberreplies = $this->boolean('jabberreplies');
 
                $user = common_current_user();
 
@@ -121,6 +125,7 @@ class ImsettingsAction extends SettingsAction {
 
                $user->jabbernotify = $jabbernotify;
                $user->updatefrompresence = $updatefrompresence;
+               $user->jabberreplies = $jabberreplies;
 
                $result = $user->update($original);
 
index 9d7d7f770334c2dd39a3b3bbe1d4729e1ad71e7c..7aaf787b2e5b22e953c34c1974042dabed0b227f 100644 (file)
@@ -4,18 +4,18 @@
  */
 require_once 'DB/DataObject.php';
 
-class Avatar extends DB_DataObject
+class Avatar extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
 
     public $__table = 'avatar';                          // table name
     public $profile_id;                      // int(4)  primary_key not_null
-    public $original;                        // tinyint(1)
+    public $original;                        // tinyint(1)  
     public $width;                           // int(4)  primary_key not_null
     public $height;                          // int(4)  primary_key not_null
     public $mediatype;                       // varchar(32)   not_null
-    public $filename;                        // varchar(255)
+    public $filename;                        // varchar(255)  
     public $url;                             // varchar(255)  unique_key
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
index 7b2962925c64360955c064c1bb6a0cd505308748..f18d554a362de0df22f078a92ce5732df2760705 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Confirm_address extends DB_DataObject
+class Confirm_address extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -15,8 +15,8 @@ class Confirm_address extends DB_DataObject
     public $address;                         // varchar(255)   not_null
     public $address_extra;                   // varchar(255)   not_null
     public $address_type;                    // varchar(8)   not_null
-    public $claimed;                         // datetime()
-    public $sent;                            // datetime()
+    public $claimed;                         // datetime()  
+    public $sent;                            // datetime()  
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
     /* Static get */
index 4b7cb414b39505ea06cf59923a8945203d3f5620..6f4513f332847652d7d28b4b7f749488e5592b42 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Consumer extends DB_DataObject
+class Consumer extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
index 1a3f3586899e6a82a71081c98c12fb6e468e70ab..987e8d1e85c1fd18b9573a3ef021d889787d5c2f 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Nonce extends DB_DataObject
+class Nonce extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
index 0ea9763cba64ba1d808444678d4e9bca8c491df1..a00114f95df2043db1a0258c7c009ceb629e6352 100644 (file)
@@ -24,7 +24,7 @@ if (!defined('LACONICA')) { exit(1); }
  */
 require_once 'DB/DataObject.php';
 
-class Notice extends DB_DataObject
+class Notice extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -33,12 +33,12 @@ class Notice extends DB_DataObject
     public $id;                              // int(4)  primary_key not_null
     public $profile_id;                      // int(4)   not_null
     public $uri;                             // varchar(255)  unique_key
-    public $content;                         // varchar(140)
-    public $rendered;                        // text()
-    public $url;                             // varchar(255)
+    public $content;                         // varchar(140)  
+    public $rendered;                        // text()  
+    public $url;                             // varchar(255)  
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
-    public $reply_to;                        // int(4)
+    public $reply_to;                        // int(4)  
 
     /* Static get */
     function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Notice',$k,$v); }
index d482e8d283a5212160c9632ad4e3b9064b16e93a..5f88caf2c41dea018614fd772b9365ff1d31f57c 100644 (file)
@@ -24,7 +24,7 @@ if (!defined('LACONICA')) { exit(1); }
  */
 require_once 'DB/DataObject.php';
 
-class Profile extends DB_DataObject
+class Profile extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -33,7 +33,7 @@ class Profile extends DB_DataObject
     public $id;                              // int(4)  primary_key not_null
     public $nickname;                        // varchar(64)  multiple_key not_null
     public $fullname;                        // varchar(255)  multiple_key
-    public $profileurl;                      // varchar(255)
+    public $profileurl;                      // varchar(255)  
     public $homepage;                        // varchar(255)  multiple_key
     public $bio;                             // varchar(140)  multiple_key
     public $location;                        // varchar(255)  multiple_key
index 4a7aeebe2822710c6a97a79989be8190e959118a..48dd2b443c86525916abf55805348ce2eba54f14 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Queue_item extends DB_DataObject
+class Queue_item extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -12,7 +12,7 @@ class Queue_item extends DB_DataObject
     public $__table = 'queue_item';                      // table name
     public $notice_id;                       // int(4)  primary_key not_null
     public $created;                         // datetime()   not_null
-    public $claimed;                         // datetime()
+    public $claimed;                         // datetime()  
 
     /* Static get */
     function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Queue_item',$k,$v); }
index 31a09ab4131a219d04699e3d46c49fdcfcc42d16..c84668c46b8404b41b564b7ea6f5e72fd925342e 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Remember_me extends DB_DataObject
+class Remember_me extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
index 216c989e7d0b12b51601e1bbbaf61be69c8346fe..e5613125dcf5d564f5ae8aec77ecb07887a87ed6 100644 (file)
@@ -24,7 +24,7 @@ if (!defined('LACONICA')) { exit(1); }
  */
 require_once 'DB/DataObject.php';
 
-class Remote_profile extends DB_DataObject
+class Remote_profile extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -32,8 +32,8 @@ class Remote_profile extends DB_DataObject
     public $__table = 'remote_profile';                  // table name
     public $id;                              // int(4)  primary_key not_null
     public $uri;                             // varchar(255)  unique_key
-    public $postnoticeurl;                   // varchar(255)
-    public $updateprofileurl;                // varchar(255)
+    public $postnoticeurl;                   // varchar(255)  
+    public $updateprofileurl;                // varchar(255)  
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
index 2fb7a99f4ae6bded6b2adb99b5596ae787650662..8e26f1684ebcd874698e2e7ef2c865a7dabdc76e 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Reply extends DB_DataObject
+class Reply extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -12,8 +12,8 @@ class Reply extends DB_DataObject
     public $__table = 'reply';                           // table name
     public $notice_id;                       // int(4)  primary_key not_null
     public $profile_id;                      // int(4)  primary_key not_null
-    public $replied_id;                      // int(4)
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
+    public $replied_id;                      // int(4)  
 
     /* Static get */
     function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Reply',$k,$v); }
index 45bb29cffa5eeeaf4cd80f7356c2a0540e884cd7..5fb7417317a5a1ad03c8f20bf9e5136fe159544a 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Sms_carrier extends DB_DataObject
+class Sms_carrier extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
index dd7b0f3dbba62995de2a7c626abdcf574ae9e0ef..2a1037d2bc1ca292f37b38c114ebb9addd164e35 100644 (file)
@@ -24,7 +24,7 @@ if (!defined('LACONICA')) { exit(1); }
  */
 require_once 'DB/DataObject.php';
 
-class Subscription extends DB_DataObject
+class Subscription extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -32,8 +32,8 @@ class Subscription extends DB_DataObject
     public $__table = 'subscription';                    // table name
     public $subscriber;                      // int(4)  primary_key not_null
     public $subscribed;                      // int(4)  primary_key not_null
-    public $token;                           // varchar(255)
-    public $secret;                          // varchar(255)
+    public $token;                           // varchar(255)  
+    public $secret;                          // varchar(255)  
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
index cd14fbfffff4b6e74deed3d2e592f51ecc7f9017..a91b19f8e7dcbb464d92a0e063d0665d90d94221 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class Token extends DB_DataObject
+class Token extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -14,7 +14,7 @@ class Token extends DB_DataObject
     public $tok;                             // char(32)  primary_key not_null
     public $secret;                          // char(32)   not_null
     public $type;                            // tinyint(1)   not_null
-    public $state;                           // tinyint(1)
+    public $state;                           // tinyint(1)  
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
index b928b69cacb2a63e19cdc7387dc44ec9cd996191..e5046a394f7df22c7dbddaa6e9da22cdf38b2049 100644 (file)
@@ -24,7 +24,7 @@ if (!defined('LACONICA')) { exit(1); }
 require_once 'DB/DataObject.php';
 require_once 'Validate.php';
 
-class User extends DB_DataObject
+class User extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -32,14 +32,15 @@ class User extends DB_DataObject
     public $__table = 'user';                            // table name
     public $id;                              // int(4)  primary_key not_null
     public $nickname;                        // varchar(64)  unique_key
-    public $password;                        // varchar(255)
+    public $password;                        // varchar(255)  
     public $email;                           // varchar(255)  unique_key
     public $jabber;                          // varchar(255)  unique_key
-    public $jabbernotify;                    // tinyint(1)
-    public $updatefrompresence;              // tinyint(1)
+    public $jabbernotify;                    // tinyint(1)  
+    public $jabberreplies;                   // tinyint(1)  
+    public $updatefrompresence;              // tinyint(1)  
     public $sms;                             // varchar(64)  unique_key
-    public $carrier;                         // int(4)
-    public $smsnotify;                       // tinyint(1)
+    public $carrier;                         // int(4)  
+    public $smsnotify;                       // tinyint(1)  
     public $uri;                             // varchar(255)  unique_key
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
index b199685f8ed50ef377f3ac838a14e3126971e373..67f6f3b2efa592e419a68ff38bbcbacd98c99b41 100644 (file)
@@ -4,7 +4,7 @@
  */
 require_once 'DB/DataObject.php';
 
-class User_openid extends DB_DataObject
+class User_openid extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
index d03a3ffa046fded08413899499473cdf8684789d..8b1708afbc5f0a81be02fcd604091c1319235c00 100644 (file)
@@ -159,6 +159,7 @@ password = 2
 email = 2
 jabber = 2
 jabbernotify = 17
+jabberreplies = 17
 updatefrompresence = 17
 sms = 2
 carrier = 1
index 42a00da3f0c1b62011cab9603ea1ba14a88f7036..4115b84ec510662abe1588c3007756c14f755967 100644 (file)
@@ -47,6 +47,7 @@ create table user (
     email varchar(255) unique key comment 'email address for password recovery etc.',
     jabber varchar(255) unique key comment 'jabber ID for notices',
     jabbernotify tinyint default 0 comment 'whether to send notices to jabber',
+    jabberreplies tinyint default 0 comment 'whether to send notices to jabber on replies',
     updatefrompresence tinyint default 0 comment 'whether to record updates from Jabber presence notices',
     sms varchar(64) unique key comment 'sms phone number',
     carrier integer comment 'foreign key to sms_carrier' references sms_carrier (id),
index bd04edc63e8344aa29cad80e23e95e1dd22ab571..b0dc24bd0dfdab0a5f775dbcdfd2d7dc5ac0cba1 100644 (file)
@@ -194,8 +194,6 @@ function jabber_special_presence($type, $to=NULL, $show=NULL, $status=NULL) {
 }
 
 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 ' .
@@ -203,23 +201,50 @@ function jabber_broadcast_notice($notice) {
                           __FILE__);
                return false;
        }
+       $sent_to = array();
+       # First, get users who this is a direct reply to
+       $reply = new Reply();
+       $reply->notice_id = $notice->id;
+       if ($reply->find()) {
+               while ($reply->fetch()) {
+                       $user = User::staticGet($reply->profile_id);
+                       if ($user && $user->jabber && $user->jabbernotify && $user->jabberreplies) {
+                               common_log(LOG_INFO,
+                                                  'Sending reply notice ' . $notice->id . ' to ' . $user->jabber,
+                                                  __FILE__);
+                               $success = jabber_send_notice($user->jabber, $notice);
+                               if ($success) {
+                                       # Remember so we don't send twice
+                                       $sent_to[$user->id] = true;
+                               } else {
+                                       # XXX: Not sure, but I think that's the right thing to do
+                                       return false;
+                               }
+                       }
+               }
+       }
+    # Now, get users subscribed to this profile
+       # XXX: use a join here rather than looping through results
        $sub = new Subscription();
        $sub->subscribed = $notice->profile_id;
+        
        if ($sub->find()) {
                while ($sub->fetch()) {
                        $user = User::staticGet($sub->subscriber);
-                       if ($user && $user->jabber && $user->jabbernotify) {
+                       if ($user && $user->jabber && $user->jabbernotify && !$sent_to[$user->id]) {
                                common_log(LOG_INFO,
                                                   'Sending notice ' . $notice->id . ' to ' . $user->jabber,
                                                   __FILE__);
                                $success = jabber_send_notice($user->jabber, $notice);
-                               if (!$success) {
+                               if ($success) {
+                                       $sent_to[$user->id] = true;
                                        # XXX: Not sure, but I think that's the right thing to do
                                        return false;
                                }
                        }
                }
        }
+
        return true;
 }