forked from GNUsocial/gnu-social
Reworked the ActivityContext->attention structure
Removing Evan's obscure attentionType solution and directly using the attention array
This commit is contained in:
@@ -78,14 +78,13 @@ class GroupsalmonAction extends SalmonAction
|
||||
}
|
||||
|
||||
// Notice must be to the attention of this group
|
||||
$context = $this->activity->context;
|
||||
|
||||
if (empty($context->attention)) {
|
||||
if (empty($this->activity->context->attention)) {
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException("Not to the attention of anyone.");
|
||||
} else {
|
||||
$uri = common_local_url('groupbyid', array('id' => $this->group->id));
|
||||
if (!in_array($uri, $context->attention)) {
|
||||
|
||||
if (!array_key_exists($uri, $this->activity->context->attention)) {
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException("Not to the attention of this group.");
|
||||
}
|
||||
|
@@ -91,9 +91,9 @@ class UsersalmonAction extends SalmonAction
|
||||
throw new ClientException(_m('In reply to a notice not by this user and not mentioning this user.'));
|
||||
}
|
||||
} else if (!empty($context->attention)) {
|
||||
if (!in_array($this->user->uri, $context->attention) &&
|
||||
!in_array(common_profile_url($this->user->nickname), $context->attention)) {
|
||||
common_log(LOG_ERR, "{$this->user->uri} not in attention list (".implode(',', $context->attention).")");
|
||||
if (!array_key_exists($this->user->uri, $context->attention) &&
|
||||
!array_key_exists(common_profile_url($this->user->nickname), $context->attention)) {
|
||||
common_log(LOG_ERR, "{$this->user->uri} not in attention list (".implode(',', array_keys($context->attention)).')');
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException(_m('To the attention of user(s), not including this one.'));
|
||||
}
|
||||
|
@@ -656,10 +656,9 @@ class Ostatus_profile extends Managed_DataObject
|
||||
}
|
||||
|
||||
if ($activity->context) {
|
||||
// Any individual or group attn: targets?
|
||||
$replies = $activity->context->attention;
|
||||
$options['groups'] = $this->filterReplies($oprofile, $replies);
|
||||
$options['replies'] = $replies;
|
||||
// TODO: context->attention
|
||||
list($options['groups'], $options['replies'])
|
||||
= $this->filterReplies($oprofile, $activity->context->attention);
|
||||
|
||||
// Maintain direct reply associations
|
||||
// @todo FIXME: What about conversation ID?
|
||||
@@ -826,10 +825,9 @@ class Ostatus_profile extends Managed_DataObject
|
||||
}
|
||||
|
||||
if ($activity->context) {
|
||||
// Any individual or group attn: targets?
|
||||
$replies = $activity->context->attention;
|
||||
$options['groups'] = $this->filterReplies($oprofile, $replies);
|
||||
$options['replies'] = $replies;
|
||||
// TODO: context->attention
|
||||
list($options['groups'], $options['replies'])
|
||||
= $this->filterReplies($oprofile, $activity->context->attention);
|
||||
|
||||
// Maintain direct reply associations
|
||||
// @todo FIXME: What about conversation ID?
|
||||
@@ -908,26 +906,26 @@ class Ostatus_profile extends Managed_DataObject
|
||||
* @param array in/out &$attention_uris set of URIs, will be pruned on output
|
||||
* @return array of group IDs
|
||||
*/
|
||||
protected function filterReplies($sender, &$attention_uris)
|
||||
protected function filterReplies($sender, array $attention)
|
||||
{
|
||||
common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', $attention_uris));
|
||||
common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', $attention));
|
||||
$groups = array();
|
||||
$replies = array();
|
||||
foreach (array_unique($attention_uris) as $recipient) {
|
||||
foreach ($attention as $recipient=>$type) {
|
||||
// Is the recipient a local user?
|
||||
$user = User::getKV('uri', $recipient);
|
||||
if ($user) {
|
||||
if ($user instanceof User) {
|
||||
// @todo FIXME: Sender verification, spam etc?
|
||||
$replies[] = $recipient;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is the recipient a local group?
|
||||
// $group = User_group::getKV('uri', $recipient);
|
||||
// TODO: $group = User_group::getKV('uri', $recipient);
|
||||
$id = OStatusPlugin::localGroupFromUrl($recipient);
|
||||
if ($id) {
|
||||
$group = User_group::getKV('id', $id);
|
||||
if ($group) {
|
||||
if ($group instanceof User_group) {
|
||||
// Deliver to all members of this local group if allowed.
|
||||
$profile = $sender->localProfile();
|
||||
if ($profile->isMember($group)) {
|
||||
@@ -959,10 +957,9 @@ class Ostatus_profile extends Managed_DataObject
|
||||
}
|
||||
|
||||
}
|
||||
$attention_uris = $replies;
|
||||
common_log(LOG_DEBUG, "Local reply recipients: " . implode(', ', $replies));
|
||||
common_log(LOG_DEBUG, "Local group recipients: " . implode(', ', $groups));
|
||||
return $groups;
|
||||
return array($groups, $replies);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user