diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2016-11-25 07:54:49 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2016-11-25 07:56:16 +0100 |
| commit | acf02a1269b9c191a66a7ea476f11d53d4ad0c08 (patch) | |
| tree | 94332bd05859677747c4ffaad857b79f0c4351e2 /src | |
| parent | dd3e0698a71ca2746166f006135aeace83dfeb20 (diff) | |
| download | phinde-acf02a1269b9c191a66a7ea476f11d53d4ad0c08.tar.gz phinde-acf02a1269b9c191a66a7ea476f11d53d4ad0c08.zip | |
script to renew websub subscriptionsv0.2.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/phinde/Subscriptions.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/phinde/Subscriptions.php b/src/phinde/Subscriptions.php index 5aac9b2..87119c8 100644 --- a/src/phinde/Subscriptions.php +++ b/src/phinde/Subscriptions.php @@ -60,6 +60,23 @@ class Subscriptions } /** + * Get all topics that either expired or expire soon + * + * @return \PDOStatement Result iterator + */ + public function getExpiring() + { + $stmt = $this->db->prepare( + 'SELECT * FROM subscriptions' + . ' WHERE sub_status IN ("active", "expired")' + . ' AND DATEDIFF(sub_expires, NOW()) <= 2' + ); + $stmt->execute(); + + return $stmt; + } + + /** * Create a new subscription entry in database. * Automatically generates secret, capkey and lease seconds. * @@ -95,6 +112,23 @@ class Subscriptions } /** + * Renew a subscription: Set its status to "subscribing" + * + * @param integer $subId Subscription ID + * + * @return void + */ + public function renew($subId) + { + $this->db->prepare( + 'UPDATE subscriptions' + . ' SET sub_status = "subscribing"' + . ' , sub_updated = NOW()' + . ' WHERE sub_id = :id' + )->execute([':id' => $subId]); + } + + /** * A subscription has been confirmed by the hub - mark it as active. * * @param integer $subId Subscription ID @@ -137,6 +171,14 @@ class Subscriptions )->execute([':id' => $subId]); } + /** + * Subscription has been cancelled/denied for some reason + * + * @param integer $subId Subscription ID + * @param string $reason Cancellation reason + * + * @return void + */ public function denied($subId, $reason) { $this->db->prepare( @@ -148,6 +190,13 @@ class Subscriptions )->execute([':id' => $subId, ':reason' => $reason]); } + /** + * Topic update notification has been received + * + * @param integer $subId Subscription ID + * + * @return void + */ public function pinged($subId) { $this->db->prepare( |
