Browse Source

Use the MUC resource to check if the user is allowed to react or not

Decorate the reactions buttons if already reacted (only based on full jid yet)
pull/826/head
Timothée Jaussoin 7 years ago
parent
commit
85ac99d0f4
  1. 46
      app/widgets/Chat/Chat.php
  2. 1
      app/widgets/Chat/_chat_reactions.tpl
  3. 5
      app/widgets/Chat/chat.css

46
app/widgets/Chat/Chat.php

@ -439,20 +439,33 @@ class Chat extends \Movim\Widget\Base
->where('mid', $mid)
->first();
if ($message
&& $message->reactions()
->where('emoji', $emoji)
->where('jidfrom', ($message->type == 'groupchat')
? $this->user->session->username
: $this->user->id)
->count() == 0) {
$this->ajaxHttpSendMessage(
$message->jidfrom != $message->user_id
? $message->jidfrom
: $message->jidto,
$emoji, $message->type == 'groupchat',
false, false, false, $message->replaceid
);
if ($message) {
// Try to load the MUC presence and resolve the resource
$mucPresence = null;
if ($message->type == 'groupchat') {
$mucPresence = $this->user->session->presences()
->where('jid', $message->jidfrom)
->where('mucjid', $this->user->id)
->where('muc', true)
->first();
if (!$mucPresence) return;
}
if ($message->reactions()
->where('emoji', $emoji)
->where('jidfrom', ($message->type == 'groupchat')
? $mucPresence->resource
: $this->user->id)
->count() == 0) {
$this->ajaxHttpSendMessage(
$message->jidfrom != $message->user_id
? $message->jidfrom
: $message->jidto,
$emoji, $message->type == 'groupchat',
false, false, false, $message->replaceid
);
}
}
}
@ -855,8 +868,9 @@ class Chat extends \Movim\Widget\Base
$view->assign('message', $message);
$start = Message::where(
['type' =>'jingle_start',
'thread'=> $message->thread
[
'type' =>'jingle_start',
'thread'=> $message->thread
]
)->first();

1
app/widgets/Chat/_chat_reactions.tpl

@ -1,5 +1,6 @@
{loop="$reactions"}
<li title="{$value|implode:', '}"
{if="in_array($me, $value)"}class="reacted"{/if}
onclick="Chat_ajaxHttpSendReaction('{$message->mid}', '{$key}')">
{autoescape="off"}
{$key|addEmojis:true}

5
app/widgets/Chat/chat.css

@ -286,6 +286,11 @@ table.emojis td:hover {
background-color: rgba(var(--movim-font), 0.2);
}
#chat_widget .bubble ul.reactions li.reacted {
border: 1px solid rgba(var(--movim-font), 0.3);
box-sizing: border-box;
}
#chat_widget .bubble ul.reactions li img {
width: 2.25rem;
height: 3rem;

Loading…
Cancel
Save