summaryrefslogtreecommitdiff
path: root/plugins/OStatus/OStatusPlugin.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-24 20:36:36 +0000
committerBrion Vibber <brion@pobox.com>2010-02-24 20:36:36 +0000
commitc36bdc1ba535dc3e2dc9098dbe40735b1955d96d (patch)
tree8ff364c7042cf8fc4e24327982a9ddae9e20031c /plugins/OStatus/OStatusPlugin.php
parent07214f1370547fcc64db34ce8c8a84ec70e0d5bd (diff)
- break OMB profile update pings to a background queue
- add event hooks to profile update pings - send Salmon pings with custom update-profile event to OStatus subscribees and groups (subscribers will see it on your next post) - fix OStatus queues with overlong transport names, should work on DB queues now - Ostatus_profile::notifyActivity() and ::notifyDeferred() now can take XML, Notice, or Activity for convenience
Diffstat (limited to 'plugins/OStatus/OStatusPlugin.php')
-rw-r--r--plugins/OStatus/OStatusPlugin.php53
1 files changed, 50 insertions, 3 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 9376c048d..90abe034d 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -82,14 +82,14 @@ class OStatusPlugin extends Plugin
$qm->connect('ostatus', 'OStatusQueueHandler');
// Outgoing from our internal PuSH hub
- $qm->connect('hubverify', 'HubVerifyQueueHandler');
+ $qm->connect('hubconf', 'HubConfQueueHandler');
$qm->connect('hubout', 'HubOutQueueHandler');
// Outgoing Salmon replies (when we don't need a return value)
- $qm->connect('salmonout', 'SalmonOutQueueHandler');
+ $qm->connect('salmon', 'SalmonQueueHandler');
// Incoming from a foreign PuSH hub
- $qm->connect('pushinput', 'PushInputQueueHandler');
+ $qm->connect('pushin', 'PushInQueueHandler');
return true;
}
@@ -656,4 +656,51 @@ class OStatusPlugin extends Plugin
return true;
}
+
+ /**
+ * Ping remote profiles with updates to this profile.
+ * Salmon pings are queued for background processing.
+ */
+ function onEndBroadcastProfile(Profile $profile)
+ {
+ $user = User::staticGet('id', $profile->id);
+
+ // Find foreign accounts I'm subscribed to that support Salmon pings.
+ //
+ // @fixme we could run updates through the PuSH feed too,
+ // in which case we can skip Salmon pings to folks who
+ // are also subscribed to me.
+ $sql = "SELECT * FROM ostatus_profile " .
+ "WHERE profile_id IN " .
+ "(SELECT subscribed FROM subscription WHERE subscriber=%d) " .
+ "OR group_id IN " .
+ "(SELECT group_id FROM group_member WHERE profile_id=%d)";
+ $oprofile = new Ostatus_profile();
+ $oprofile->query(sprintf($sql, $profile->id, $profile->id));
+
+ if ($oprofile->N == 0) {
+ common_log(LOG_DEBUG, "No OStatus remote subscribees for $profile->nickname");
+ return true;
+ }
+
+ $act = new Activity();
+
+ $act->verb = ActivityVerb::UPDATE_PROFILE;
+ $act->id = TagURI::mint('update-profile:%d:%s',
+ $profile->id,
+ common_date_iso8601(time()));
+ $act->time = time();
+ $act->title = _m("Profile update");
+ $act->content = sprintf(_m("%s has updated their profile page."),
+ $profile->getBestName());
+
+ $act->actor = ActivityObject::fromProfile($profile);
+ $act->object = $act->actor;
+
+ while ($oprofile->fetch()) {
+ $oprofile->notifyDeferred($act);
+ }
+
+ return true;
+ }
}