X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=classes%2FSubscription.php;h=5ac95f92222a1aa9b80f12b5610859645a9b1510;hb=17c50f338ceb574780476f6b788f48e2d7d06017;hp=d6fb3fcbdda82f17d70dcce6692868dfed6f1840;hpb=3c61f45de1226b22eeb83bd1f6db01984f953737;p=quix0rs-gnu-social.git diff --git a/classes/Subscription.php b/classes/Subscription.php index d6fb3fcbdd..5ac95f9222 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -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) {