- 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
This commit is contained in:
Brion Vibber
2010-02-24 20:36:36 +00:00
parent 07214f1370
commit c36bdc1ba5
12 changed files with 170 additions and 41 deletions

View File

@@ -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;
}
}