]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Subscription.php
Remove hkit and do our own hcard parsing
[quix0rs-gnu-social.git] / classes / Subscription.php
index d6fb3fcbdda82f17d70dcce6692868dfed6f1840..5ac95f92222a1aa9b80f12b5610859645a9b1510 100644 (file)
@@ -105,8 +105,8 @@ class Subscription extends Memcached_DataObject
 
                 $auto = new Subscription();
 
-                $auto->subscriber = $subscriber->id;
-                $auto->subscribed = $other->id;
+                $auto->subscriber = $other->id;
+                $auto->subscribed = $subscriber->id;
                 $auto->created    = common_sql_now();
 
                 $result = $auto->insert();
@@ -172,6 +172,28 @@ class Subscription extends Memcached_DataObject
 
             assert(!empty($sub));
 
+            // @todo: move this block to EndSubscribe handler for
+            // OMB plugin when it exists.
+
+            if (!empty($sub->token)) {
+
+                $token = new Token();
+
+                $token->tok    = $sub->token;
+
+                if ($token->find(true)) {
+
+                    $result = $token->delete();
+
+                    if (!$result) {
+                        common_log_db_error($token, 'DELETE', __FILE__);
+                        throw new Exception(_('Couldn\'t delete subscription OMB token.'));
+                    }
+                } else {
+                    common_log(LOG_ERR, "Couldn't find credentials with token {$token->tok}");
+                }
+            }
+
             $result = $sub->delete();
 
             if (!$result) {