DirectMessagePlugin actions modernified
This commit is contained in:
parent
ed3022adc1
commit
62c6ed58ba
|
@ -30,9 +30,7 @@
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a list of direct messages from or to the authenticating user
|
* Show a list of direct messages from or to the authenticating user
|
||||||
|
@ -62,13 +60,11 @@ class ApiDirectMessageAction extends ApiAuthAction
|
||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
*/
|
*/
|
||||||
function prepare($args)
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->user = $this->auth_user;
|
if (!$this->scoped instanceof Profile) {
|
||||||
|
|
||||||
if (empty($this->user)) {
|
|
||||||
// TRANS: Client error given when a user was not found (404).
|
// TRANS: Client error given when a user was not found (404).
|
||||||
$this->clientError(_('No such user.'), 404);
|
$this->clientError(_('No such user.'), 404);
|
||||||
}
|
}
|
||||||
|
@ -83,30 +79,30 @@ class ApiDirectMessageAction extends ApiAuthAction
|
||||||
$this->title = sprintf(
|
$this->title = sprintf(
|
||||||
// TRANS: Title. %s is a user nickname.
|
// TRANS: Title. %s is a user nickname.
|
||||||
_("Direct messages from %s"),
|
_("Direct messages from %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->subtitle = sprintf(
|
$this->subtitle = sprintf(
|
||||||
// TRANS: Subtitle. %s is a user nickname.
|
// TRANS: Subtitle. %s is a user nickname.
|
||||||
_("All the direct messages sent from %s"),
|
_("All the direct messages sent from %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->link = $server . $this->user->nickname . '/outbox';
|
$this->link = $server . $this->scoped->getNickname() . '/outbox';
|
||||||
$this->selfuri_base = common_root_url() . 'api/direct_messages/sent';
|
$this->selfuri_base = common_root_url() . 'api/direct_messages/sent';
|
||||||
$this->id = "tag:$taguribase:SentDirectMessages:" . $this->user->id;
|
$this->id = "tag:$taguribase:SentDirectMessages:" . $this->scoped->getID();
|
||||||
} else {
|
} else {
|
||||||
$this->title = sprintf(
|
$this->title = sprintf(
|
||||||
// TRANS: Title. %s is a user nickname.
|
// TRANS: Title. %s is a user nickname.
|
||||||
_("Direct messages to %s"),
|
_("Direct messages to %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->subtitle = sprintf(
|
$this->subtitle = sprintf(
|
||||||
// TRANS: Subtitle. %s is a user nickname.
|
// TRANS: Subtitle. %s is a user nickname.
|
||||||
_("All the direct messages sent to %s"),
|
_("All the direct messages sent to %s"),
|
||||||
$this->user->nickname
|
$this->scoped->getNickname()
|
||||||
);
|
);
|
||||||
$this->link = $server . $this->user->nickname . '/inbox';
|
$this->link = $server . $this->scoped->getNickname() . '/inbox';
|
||||||
$this->selfuri_base = common_root_url() . 'api/direct_messages';
|
$this->selfuri_base = common_root_url() . 'api/direct_messages';
|
||||||
$this->id = "tag:$taguribase:DirectMessages:" . $this->user->id;
|
$this->id = "tag:$taguribase:DirectMessages:" . $this->scoped->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->messages = $this->getMessages();
|
$this->messages = $this->getMessages();
|
||||||
|
@ -166,9 +162,9 @@ class ApiDirectMessageAction extends ApiAuthAction
|
||||||
$message = new Message();
|
$message = new Message();
|
||||||
|
|
||||||
if ($this->arg('sent')) {
|
if ($this->arg('sent')) {
|
||||||
$message->from_profile = $this->user->id;
|
$message->from_profile = $this->scoped->getID();
|
||||||
} else {
|
} else {
|
||||||
$message->to_profile = $this->user->id;
|
$message->to_profile = $this->scoped->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->max_id)) {
|
if (!empty($this->max_id)) {
|
||||||
|
|
|
@ -30,9 +30,7 @@
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new direct message from the authenticating user to
|
* Creates a new direct message from the authenticating user to
|
||||||
|
@ -65,7 +63,7 @@ class ApiDirectMessageNewAction extends ApiAuthAction
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
if (empty($this->user)) {
|
if (!$this->scoped instanceof Profile) {
|
||||||
// TRANS: Client error when user not found for an API direct message action.
|
// TRANS: Client error when user not found for an API direct message action.
|
||||||
$this->clientError(_('No such user.'), 404);
|
$this->clientError(_('No such user.'), 404);
|
||||||
}
|
}
|
||||||
|
@ -111,10 +109,10 @@ class ApiDirectMessageNewAction extends ApiAuthAction
|
||||||
if (!$this->other instanceof Profile) {
|
if (!$this->other instanceof Profile) {
|
||||||
// TRANS: Client error displayed if a recipient user could not be found (403).
|
// TRANS: Client error displayed if a recipient user could not be found (403).
|
||||||
$this->clientError(_('Recipient user not found.'), 403);
|
$this->clientError(_('Recipient user not found.'), 403);
|
||||||
} else if (!$this->user->mutuallySubscribed($this->other)) {
|
} else if (!$this->scoped->mutuallySubscribed($this->other)) {
|
||||||
// TRANS: Client error displayed trying to direct message another user who's not a friend (403).
|
// TRANS: Client error displayed trying to direct message another user who's not a friend (403).
|
||||||
$this->clientError(_('Cannot send direct messages to users who aren\'t your friend.'), 403);
|
$this->clientError(_('Cannot send direct messages to users who aren\'t your friend.'), 403);
|
||||||
} else if ($this->user->id == $this->other->id) {
|
} else if ($this->scoped->getID() === $this->other->getID()) {
|
||||||
|
|
||||||
// Note: sending msgs to yourself is allowed by Twitter
|
// Note: sending msgs to yourself is allowed by Twitter
|
||||||
|
|
||||||
|
@ -123,8 +121,8 @@ class ApiDirectMessageNewAction extends ApiAuthAction
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = Message::saveNew(
|
$message = Message::saveNew(
|
||||||
$this->user->id,
|
$this->scoped->getID(),
|
||||||
$this->other->id,
|
$this->other->getID(),
|
||||||
html_entity_decode($this->content, ENT_NOQUOTES, 'UTF-8'),
|
html_entity_decode($this->content, ENT_NOQUOTES, 'UTF-8'),
|
||||||
$this->source
|
$this->source
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user