Show what you're replying to in the web interface

This commit is contained in:
Mikael Nordfeldth 2017-04-30 10:37:21 +02:00
parent 16880de8f6
commit bb72229d6a

View File

@ -47,6 +47,8 @@ class NewnoticeAction extends FormAction
{ {
protected $form = 'Notice'; protected $form = 'Notice';
protected $inreplyto = null;
/** /**
* Title of the page * Title of the page
* *
@ -75,6 +77,11 @@ class NewnoticeAction extends FormAction
} }
} }
if ($this->int('inreplyto')) {
// Throws exception if the inreplyto Notice is given but not found.
$this->inreplyto = Notice::getByID($this->int('inreplyto'));
}
// Backwards compatibility for "share this" widget things. // Backwards compatibility for "share this" widget things.
// If no 'content', use 'status_textarea' // If no 'content', use 'status_textarea'
$this->formOpts['content'] = $this->trimmed('content') ?: $this->trimmed('status_textarea'); $this->formOpts['content'] = $this->trimmed('content') ?: $this->trimmed('status_textarea');
@ -132,13 +139,6 @@ class NewnoticeAction extends FormAction
return; return;
} }
if ($this->int('inreplyto')) {
// Throws exception if the inreplyto Notice is given but not found.
$parent = Notice::getByID($this->int('inreplyto'));
} else {
$parent = null;
}
$act = new Activity(); $act = new Activity();
$act->verb = ActivityVerb::POST; $act->verb = ActivityVerb::POST;
$act->time = time(); $act->time = time();
@ -157,9 +157,9 @@ class NewnoticeAction extends FormAction
$act->context = new ActivityContext(); $act->context = new ActivityContext();
if ($parent instanceof Notice) { if ($this->inreplyto instanceof Notice) {
$act->context->replyToID = $parent->getUri(); $act->context->replyToID = $this->inreplyto->getUri();
$act->context->replyToUrl = $parent->getUrl(true); // maybe we don't have to send true here to force a URL? $act->context->replyToUrl = $this->inreplyto->getUrl(true); // maybe we don't have to send true here to force a URL?
} }
if ($this->scoped->shareLocation()) { if ($this->scoped->shareLocation()) {
@ -188,14 +188,14 @@ class NewnoticeAction extends FormAction
// FIXME: We should be able to get the attentions from common_render_content! // FIXME: We should be able to get the attentions from common_render_content!
// and maybe even directly save whether they're local or not! // and maybe even directly save whether they're local or not!
$act->context->attention = common_get_attentions($content, $this->scoped, $parent); $act->context->attention = common_get_attentions($content, $this->scoped, $this->inreplyto);
// $options gets filled with possible scoping settings // $options gets filled with possible scoping settings
ToSelector::fillActivity($this, $act, $options); ToSelector::fillActivity($this, $act, $options);
$actobj = new ActivityObject(); $actobj = new ActivityObject();
$actobj->type = ActivityObject::NOTE; $actobj->type = ActivityObject::NOTE;
$actobj->content = common_render_content($content, $this->scoped, $parent); $actobj->content = common_render_content($content, $this->scoped, $this->inreplyto);
// Finally add the activity object to our activity // Finally add the activity object to our activity
$act->objects[] = $actobj; $act->objects[] = $actobj;
@ -224,6 +224,9 @@ class NewnoticeAction extends FormAction
if ($this->getInfo() && $this->stored instanceof Notice) { if ($this->getInfo() && $this->stored instanceof Notice) {
$this->showNotice($this->stored); $this->showNotice($this->stored);
} elseif (!$this->getError()) { } elseif (!$this->getError()) {
if (!GNUsocial::isAjax() && $this->inreplyto instanceof Notice) {
$this->showNotice($this->inreplyto);
}
parent::showContent(); parent::showContent();
} }
} }