Browse Source

Fix and simplify the Comments publication flow, fix the comments list refresh on publish with the Templater

pull/1474/head
Timothée Jaussoin 1 week ago
parent
commit
bbf81d8141
  1. 8
      app/Post.php
  2. 7
      app/Widgets/Menu/Menu.php
  3. 2
      app/Widgets/Notifications/Notifications.php
  4. 3
      app/Widgets/Post/Post.php
  5. 2
      app/Widgets/Post/_post.tpl
  6. 2
      app/Widgets/Post/_post_card.tpl
  7. 6
      app/Widgets/Post/_post_comments.tpl
  8. 4
      app/Widgets/StoriesViewer/_storiesviewer.tpl
  9. 4
      src/Moxl/Xec/Action/Microblog/CommentPublish.php

8
app/Post.php

@ -824,14 +824,14 @@ class Post extends Model
return \App\Post::find($this->parent_id);
}
public function isMine($force = false): bool
public function isMine(User $me, ?bool $force = false): bool
{
if ($force) {
return ($this->aid == me()->id);
return ($this->aid == $me->id);
}
return ($this->aid == me()->id
|| $this->server == me()->id);
return ($this->aid == $me->id
|| $this->server == $me->id);
}
public function isMicroblog(): bool

7
app/Widgets/Menu/Menu.php

@ -80,7 +80,7 @@ class Menu extends Base
return;
}
if ($post->isComment() && !$post->isMine()) {
if ($post->isComment() && !$post->isMine($this->me)) {
$contact = \App\Contact::where('id', $post->aid)->first();
$parent = $post->parent;
@ -94,13 +94,14 @@ class Menu extends Base
);
}
} elseif (
$count > 0
!$post->isComment()
&& $count > 0
&& (strtotime($post->published) > strtotime($since))
) {
if ($post->isMicroblog() || $post->isStory()) {
$contact = \App\Contact::firstOrNew(['id' => $post->server]);
if (!$post->isMine()) {
if (!$post->isMine($this->me)) {
Notif::append(
'news',
'📝 ' . ($post->isStory() ? __('stories.new_story', $contact->truename) : $contact->truename),

2
app/Widgets/Notifications/Notifications.php

@ -38,7 +38,7 @@ class Notifications extends Base
{
$post = Post::find($packet->content);
if ($post && $post->isComment() && !$post->isMine()) {
if ($post && $post->isComment() && !$post->isMine($this->me)) {
$this->ajaxSetCounter();
}
}

3
app/Widgets/Post/Post.php

@ -36,11 +36,10 @@ class Post extends Base
if ($post) {
if ($post->isComment()) {
$parent = $post->getParent();
$this->rpc(
'MovimTpl.fill',
'#post_widget.' . cleanupId($parent->nodeid) . ' #comments',
$this->prepareComments($post->getParent())
$this->prepareComments($parent)
);
$this->rpc('MovimUtils.applyAutoheight');
} else {

2
app/Widgets/Post/_post.tpl

@ -7,7 +7,7 @@
<i class="material-symbols">arrow_back</i>
</span>
{if="$post->isMine() || ($post->userAffiliation && $post->userAffiliation->affiliation == 'owner')"}
{if="$post->isMine($c->me) || ($post->userAffiliation && $post->userAffiliation->affiliation == 'owner')"}
{if="$post->isEditable()"}
<span class="control icon active gray"
onclick="MovimUtils.reload('{$c->route('publish', [$post->server, $post->node, $post->nodeid])}')"

2
app/Widgets/Post/_post_card.tpl

@ -235,7 +235,7 @@
{/if}
{/if}
{if="$post->isMine() || ($post->userAffiliation && $post->userAffiliation->affiliation == 'owner')"}
{if="$post->isMine($c->me) || ($post->userAffiliation && $post->userAffiliation->affiliation == 'owner')"}
{if="$post->isEditable()"}
<a class="button narrow icon flat oppose gray on_desktop"
href="{$c->route('publish', [$post->server, $post->node, $post->nodeid])}"

6
app/Widgets/Post/_post_comments.tpl

@ -13,7 +13,7 @@
{if="$public"}
{$value->truename}{if="$key + 1 < $post->likes->count()"},{/if}
{else}
{if="$value->isMine()"}
{if="$value->isMine($c->me)"}
{$liked = [$value->server, $value->node, $value->nodeid]}
{/if}
<a title="{$value->published|prepareDate:true,true}"
@ -41,8 +41,8 @@
{loop="$post->comments"}
{if="$value->title"}
<li id="{$value->nodeid|cleanupId}"
{if="!$public && $value->isMine(true) && $value->isLike()"}class="mine"{/if}>
{if="!$public && ($value->isMine() || $post->isMine())"}
{if="!$public && $value->isMine($c->me, true) && $value->isLike()"}class="mine"{/if}>
{if="!$public && ($value->isMine($c->me) || $post->isMine($c->me))"}
<span class="control icon gray active"
onclick="PostActions_ajaxDelete('{$value->server}', '{$value->node}', '{$value->nodeid}')">
<i class="material-symbols">delete</i>

4
app/Widgets/StoriesViewer/_storiesviewer.tpl

@ -15,7 +15,7 @@
<img src="{$story->contact->getPicture()}">
</span>
{/if}
{if="$story->isMine()"}
{if="$story->isMine($c->me)"}
<span class="control icon active" onclick="StoriesViewer.pause(); StoriesViewer_ajaxDelete('{$story->id}')">
<i class="material-symbols fill">delete</i>
</span>
@ -52,7 +52,7 @@
<p class="normal title">{autoescape="off"}{$story->title|addHashtagsLinks}{/autoescape}</p>
</div>
</li>
{if="!$story->isMine()"}
{if="!$story->isMine()$c->me"}
<li class="comment">
<span class="control icon active" onclick="StoriesViewer.sendComment({$story->id})">
<i class="material-symbols">send</i>

4
src/Moxl/Xec/Action/Microblog/CommentPublish.php

@ -68,12 +68,12 @@ class CommentPublish extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$g = new GetItem;
/*$g = new GetItem;
$g->setTo($this->_to)
->setNode($this->_node)
->setId($this->_atom->id)
->setParentId($this->_parentid)
->request();
->request();*/
$this->pack(($this->_atom->title === '♥'));
$this->deliver();

Loading…
Cancel
Save