mirror of
https://github.com/flarum/framework.git
synced 2025-02-23 04:18:58 +08:00
Allow first post to be hidden/restored
Anti-spam extensions may automatically hide the first post in a discussion, and thus we had to implement smarter permissions so discussions with zero posts wouldn't be visible to users other than the author/mods. This change allows those hidden posts to be restored again.
This commit is contained in:
parent
1ca8a27e62
commit
4a906e28ba
@ -87,21 +87,19 @@ export default {
|
|||||||
destructiveControls(post) {
|
destructiveControls(post) {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
if (post.number() !== 1) {
|
|
||||||
if (post.contentType() === 'comment' && !post.isHidden() && post.canEdit()) {
|
if (post.contentType() === 'comment' && !post.isHidden() && post.canEdit()) {
|
||||||
items.add('hide', Button.component({
|
items.add('hide', Button.component({
|
||||||
icon: 'times',
|
icon: 'times',
|
||||||
children: app.trans('core.delete'),
|
children: app.trans('core.delete'),
|
||||||
onclick: this.hideAction.bind(post)
|
onclick: this.hideAction.bind(post)
|
||||||
}));
|
}));
|
||||||
} else if ((post.contentType() !== 'comment' || post.isHidden()) && post.canDelete()) {
|
} else if (post.number() !== 1 && (post.contentType() !== 'comment' || post.isHidden()) && post.canDelete()) {
|
||||||
items.add('delete', Button.component({
|
items.add('delete', Button.component({
|
||||||
icon: 'times',
|
icon: 'times',
|
||||||
children: app.trans('core.delete_forever'),
|
children: app.trans('core.delete_forever'),
|
||||||
onclick: this.deleteAction.bind(post)
|
onclick: this.deleteAction.bind(post)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
|
@ -89,10 +89,6 @@ class CommentPost extends Post
|
|||||||
*/
|
*/
|
||||||
public function hide(User $actor = null)
|
public function hide(User $actor = null)
|
||||||
{
|
{
|
||||||
if ($this->number == 1) {
|
|
||||||
throw new DomainException('Cannot hide the first post of a discussion');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $this->hide_time) {
|
if (! $this->hide_time) {
|
||||||
$this->hide_time = time();
|
$this->hide_time = time();
|
||||||
$this->hide_user_id = $actor ? $actor->id : null;
|
$this->hide_user_id = $actor ? $actor->id : null;
|
||||||
@ -110,10 +106,6 @@ class CommentPost extends Post
|
|||||||
*/
|
*/
|
||||||
public function restore()
|
public function restore()
|
||||||
{
|
{
|
||||||
if ($this->number == 1) {
|
|
||||||
throw new DomainException('Cannot restore the first post of a discussion');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->hide_time !== null) {
|
if ($this->hide_time !== null) {
|
||||||
$this->hide_time = null;
|
$this->hide_time = null;
|
||||||
$this->hide_user_id = null;
|
$this->hide_user_id = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user