+ function saveAttentions(array $uris)
+ {
+ foreach ($uris as $uri=>$type) {
+ try {
+ $target = Profile::fromUri($uri);
+ } catch (UnknownUriException $e) {
+ common_log(LOG_WARNING, "Unable to determine profile for URI '$uri'");
+ continue;
+ }
+
+ try {
+ $this->saveAttention($target);
+ } catch (AlreadyFulfilledException $e) {
+ common_debug('Attention already exists: '.var_export($e->getMessage(),true));
+ } catch (Exception $e) {
+ common_log(LOG_ERR, "Could not save notice id=={$this->getID()} attention for profile id=={$target->getID()}: {$e->getMessage()}");
+ }
+ }
+ }
+
+ /**
+ * Saves an attention for a profile (user or group) which means
+ * it shows up in their home feed and such.
+ */
+ function saveAttention(Profile $target, $reason=null)
+ {
+ if ($target->isGroup()) {
+ // FIXME: Make sure we check (for both local and remote) users are in the groups they send to!
+
+ // legacy notification method, will still be in use for quite a while I think
+ $this->addToGroupInbox($target->getGroup());
+ } else {
+ if ($target->hasBlocked($this->getProfile())) {
+ common_log(LOG_INFO, "Not saving reply to profile {$target->id} ($uri) from sender {$sender->id} because of a block.");
+ return false;
+ }
+ }
+
+ if ($target->isLocal()) {
+ // legacy notification method, will still be in use for quite a while I think
+ $this->saveReply($target->getID());
+ }
+
+ $att = Attention::saveNew($this, $target, $reason);
+
+ self::blow('reply:stream:%d', $target->getID());
+ return true;
+ }
+