Browse Source

Fix quoted and presences handling in messages for Chatrooms

pull/617/head
Timothée Jaussoin 8 years ago
parent
commit
16615c976d
  1. 15
      app/Message.php
  2. 5
      app/Presence.php
  3. 5
      app/Session.php
  4. 17
      app/widgets/Chat/Chat.php
  5. 2
      app/widgets/Rooms/Rooms.php
  6. 2
      app/widgets/Rooms/_rooms_list.tpl

15
app/Message.php

@ -124,13 +124,16 @@ class Message extends Model
}
if ($this->type == 'groupchat') {
//$p = $pd->getMyPresenceRoom($this->jidfrom);
/*if (is_object($p)
&& strpos($this->body, $p->resource) !== false
&& $this->resource != $p->resource) {
$presence = $this->user->session->presences()
->where('jid', $this->jidfrom)
->where('mucjid', $this->user->id)
->first();
if ($presence
&& strpos($this->body, $presence->resource) !== false
&& $this->resource != $presence->resource) {
$this->quoted = true;
}*/
}
}
if ($stanza->html) {

5
app/Presence.php

@ -40,6 +40,11 @@ class Presence extends Model
return $this->hasOne('App\Contact', 'id', 'jid');
}
public function contactConference()
{
return $this->hasOne('App\Contact', 'id', 'mucjid');
}
public function getPresencetextAttribute()
{
return getPresences()[$this->value];

5
app/Session.php

@ -15,6 +15,11 @@ class Session extends Model
return $this->belongsTo('App\User');
}
public function presences()
{
return $this->hasMany('App\Presence');
}
public function presence()
{
return $this->hasOne('App\Presence', 'jid', 'user_id')

17
app/widgets/Chat/Chat.php

@ -750,20 +750,21 @@ class Chat extends \Movim\Widget\Base
}
if ($message->type == 'groupchat') {
$message->color = stringToColor($message->session . $message->resource . $message->type);
$message->color = stringToColor($message->session_id . $message->resource . $message->type);
/*$cd = new \Modl\ContactDAO;
$contact = $cd->getPresence($message->jidfrom, $message->resource);
if ($contact) {
$url = $contact->getPhoto('s');
$presence = $this->user->session->presences()
->where('jid', $message->jidfrom)
->where('resource', $message->resource)
->first();
if ($presence && $presence->contactConference) {
$url = $presence->contactConference->getPhoto('s');
if ($url) {
$message->icon_url = $url;
}
$message->mine = ($contact->mucjid == $message->session);
}*/
$message->mine = ($presence->mucjid == $this->user->id);
}
$message->icon = firstLetterCapitalize($message->resource);
}

2
app/widgets/Rooms/Rooms.php

@ -34,7 +34,7 @@ class Rooms extends \Movim\Widget\Base
{
$message = $packet->content;
if ($message->session == $message->jidto
if ($message->user_id == $message->jidto
&& $message->type == 'groupchat') {
Notification::append(
'chat|'.$message->jidfrom,

2
app/widgets/Rooms/_rooms_list.tpl

@ -10,7 +10,7 @@
<li class="{if="$value->last > 60"} inactive{/if}"
title="{$value->resource}">
{if="$value->contact && $url = $value->contact->getPhoto('s') && $value->jid != $room"}
{if="$value->contactConference && $url = $value->contactConference->getPhoto('s')"}
<span class="primary icon bubble status {$value->presencekey}">
<img src="{$url}">
</span>

Loading…
Cancel
Save