Page MenuHomePhabricator

D538.id.diff
No OneTemporary

D538.id.diff

diff --git a/bin/controllers/subscription.php b/bin/controllers/subscription.php
--- a/bin/controllers/subscription.php
+++ b/bin/controllers/subscription.php
@@ -58,8 +58,7 @@
* server, when app.* events happen, it could automatically refresh
* the application list.
*/
- $authapp = $this->authapp? db()->table('authapp')->get('appID', $this->authapp->getRemote()->getId())->first() : null;
- $subscriber = db()->table('authapp')->get('appID', $authapp && !$authapp->isSSO? $this->authapp->getRemote()->getId() : $_POST['target'])->first(true);
+ $publisher = db()->table('authapp')->get('appID', $this->authapp? $this->authapp->getSrc()->getId() : $_POST['publisher'])->first();
/*
* Check if the listener already exists for this application (to ensure
@@ -69,22 +68,21 @@
* exists, they can just parse their recipe file, push the hooks and
* let h00k do the work.
*/
- $record = $l? : (db()->table('listener')->get('subscriber', $subscriber)->where('internalId', $_POST['hid'])->first()? : db()->table('listener')->newRecord());
+ $record = $l? : (db()->table('listener')->get('publisher', $publisher)->where('name', $_POST['name'])->first()? : db()->table('listener')->newRecord());
/*
* Use the data submitted to register the hook. We make sure the data
* is validated by using Spitfire's validation mechanism in the
* annotations.
*/
- $record->internalId = $_POST['hid'];
- $record->publisher = db()->table('authapp')->get('appID', $_POST['app'])->first(true);
- $record->subscriber = $subscriber;
+ $record->name = $_POST['name'];
+ $record->publisher = $publisher;
$record->listenTo = $_POST['listen'];
$record->URL = $_POST['url'];
$record->defer = $_POST['defer'];
$record->format = $_POST['format'];
$record->transliteration = $_POST['transliteration']?? null;
- $record->createdBy = $this->authapp? 'app:' . $this->authapp->getRemote()->getId() : 'user:' . (int)$this->user;
+ $record->createdBy = $this->authapp? 'app:' . $this->authapp->getSrc()->getId() : 'user:' . (int)$this->user;
$record->store();
@@ -137,13 +135,11 @@
$app = db()->table('authapp')->get('appID', $value)->first(true);
$query->where('publisher', $app);
break;
-
- case 'subscriber';
- $app = db()->table('authapp')->get('appID', $value)->first(true);
- $query->where('subscriber', $app);
+ case 'event' :
+ $query->where('listenTo', $value);
break;
case 'name' :
- $query->where('listenTo', $value);
+ $query->where('name', $value);
break;
}
}
@@ -168,8 +164,8 @@
if ($this->authapp) {
$listener = db()->table('listener')
- ->get('app', db()->table('authapp')->get('appID', $this->authapp->getRemote()->getId()))
- ->where('internalID', $id)
+ ->get('publisher', db()->table('authapp')->get('appID', $this->authapp->getRemote()->getId()))
+ ->where('name', $id)
->first(true);
}
else {
diff --git a/bin/directors/inbox.php b/bin/directors/inbox.php
--- a/bin/directors/inbox.php
+++ b/bin/directors/inbox.php
@@ -72,7 +72,6 @@
foreach ($listeners as $listener) {
$outbox = db()->table('outbox')->newRecord();
$outbox->incoming = $record;
- $outbox->app = $listener->subscriber;
$outbox->url = $listener->URL;
$outbox->payload = $listener->transliteration? Transliteration::instance($record->payload, $listener->transliteration)->transliterate() : $record->payload;
$outbox->scheduled = $record->scheduled + $listener->defer;
diff --git a/bin/models/listener.php b/bin/models/listener.php
--- a/bin/models/listener.php
+++ b/bin/models/listener.php
@@ -27,9 +27,8 @@
* other app to authenticate CptnH00k against a PHPAS instance.
*/
$schema->publisher = new Reference('authapp');
- $schema->subscriber = new Reference('authapp');
- $schema->internalId = new StringField( 50);
+ $schema->name = new StringField( 50);
$schema->listenTo = new StringField( 50);
$schema->URL = new StringField(200);
$schema->defer = new IntegerField(true);
diff --git a/bin/templates/subscription/drop.php b/bin/templates/subscription/drop.php
--- a/bin/templates/subscription/drop.php
+++ b/bin/templates/subscription/drop.php
@@ -24,4 +24,4 @@
* THE SOFTWARE.
*/
-current_context()->response->getHeaders()->redirect(url('listener', 'registered', 'to:' . $listener->subscriber->appID));
\ No newline at end of file
+current_context()->response->getHeaders()->redirect(url('listener', 'registered', 'publisher:' . $listener->publisher->appID));
\ No newline at end of file
diff --git a/bin/templates/subscription/edit.json.php b/bin/templates/subscription/edit.json.php
--- a/bin/templates/subscription/edit.json.php
+++ b/bin/templates/subscription/edit.json.php
@@ -27,7 +27,7 @@
if (!isset($messages)) {
echo json_encode([
'success' => true,
- 'id' => $success->subscriber->appID . ':' . $success->internalId
+ 'id' => $success->publisher->appID . ':' . $success->internalId
]);
}
else {
diff --git a/bin/templates/subscription/edit.php b/bin/templates/subscription/edit.php
--- a/bin/templates/subscription/edit.php
+++ b/bin/templates/subscription/edit.php
@@ -24,7 +24,7 @@
<div class="spacer" style="height : 20px"></div>
- <div class="row l6 m3">
+ <div class="row l3 m3">
<div class="span l1 m1">
<label>Publisher</label>
</div>
@@ -36,17 +36,6 @@
<?php endforeach; ?>
</select>
</div>
- <div class="span l1 m1">
- <label>Subscriber</label>
- </div>
- <div class="span l2 m2">
- <select class="styled-select" name="target" style="width: 100%">
- <option value="">---</option>
- <?php foreach ($apps as $app): ?>
- <option value="<?= $app->appID ?>" <?= $listener && $listener->subscriber->_id === $app->_id? 'selected' : '' ?>><?= $app->name ?></option>
- <?php endforeach; ?>
- </select>
- </div>
</div>
<div class="spacer" style="height : 15px"></div>
@@ -56,10 +45,10 @@
<label>Identifier</label>
</div>
<div class="span l2">
- <input type="text" name="hid" style="width: 100%" value="<?= $listener? __($listener->internalId) : '' ?>">
+ <input type="text" name="name" style="width: 100%" value="<?= $listener? __($listener->name) : '' ?>">
<p class="small secondary">
- Used for reference, must be unique for the target app. When creating
- two hooks with the same subscriber and ID combination, the first one will
+ Used for reference, must be unique for the publisher app. When creating
+ two hooks with the same publisher and name combination, the first one will
be overwritten.
</p>
</div>
@@ -71,7 +60,7 @@
<p class="small secondary">
The event name is provided by the publishing application, whenever
the publisher distributes an event with the given name (or a child)
- the subscriber will be notified.
+ the URL you provide will be invoked.
</p>
</div>
</div>
diff --git a/bin/templates/subscription/registered.json.php b/bin/templates/subscription/registered.json.php
--- a/bin/templates/subscription/registered.json.php
+++ b/bin/templates/subscription/registered.json.php
@@ -31,8 +31,7 @@
'id' => $listener->internalId,
'on' => [
'event' => $listener->listenTo,
- 'from' => $listener->publisher->appID,
- 'to' => $listener->subscriber->appID
+ 'from' => $listener->publisher->appID
],
'url' => $listener->URL,
'defer' => $listener->defer

File Metadata

Mime Type
text/plain
Expires
Apr 11 2021, 1:14 PM (9 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5612
Default Alt Text
D538.id.diff (7 KB)

Event Timeline