- # XXX: use a join here rather than looping through results
- $sub = new Subscription();
- $sub->subscribed = $notice->profile_id;
- if ($sub->find()) {
- $posted = array();
- while ($sub->fetch()) {
- $rp = Remote_profile::staticGet('id', $sub->subscriber);
- if ($rp) {
- if (!$posted[$rp->postnoticeurl]) {
- if (omb_post_notice($notice, $rp, $sub)) {
- $posted[$rp->postnoticeurl] = TRUE;
- }
- }
+ $rp = new Remote_profile();
+
+ $rp->query('SELECT postnoticeurl, token, secret ' .
+ 'FROM subscription JOIN remote_profile ' .
+ 'ON subscription.subscriber = remote_profile.id ' .
+ 'WHERE subscription.subscribed = ' . $notice->profile_id . ' ');
+
+ $posted = array();
+
+ while ($rp->fetch()) {
+ if (!$posted[$rp->postnoticeurl]) {
+ common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl);
+ if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) {
+ common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl);
+ $posted[$rp->postnoticeurl] = TRUE;
+ } else {
+ common_log(LOG_DEBUG, 'Failed posting to ' . $rp->postnoticeurl);