|
@@ -347,8 +347,23 @@ class member_talkControl extends mbMemberControl
|
|
|
private function talk_rooms($user,$local_last)
|
|
|
{
|
|
|
$mod_room = Model('room');
|
|
|
- $items = $mod_room->getLastRoomMsg($user);
|
|
|
- $ret = $this->talk_format($items,'room',$user,$local_last);
|
|
|
+
|
|
|
+ $join_rooms = $mod_room->getJoinedRooms(['member_id'=>$user,'state'=>0]);
|
|
|
+ $roomids = [];
|
|
|
+ if(!empty($join_rooms)) {
|
|
|
+ foreach ($join_rooms as $room){$roomids[] = $room['room_id'];}
|
|
|
+ }
|
|
|
+
|
|
|
+ $chat_rooms = $mod_room->getRooms(['type'=>proto_type::room_chat,'room_id'=>['in',$roomids]]);
|
|
|
+ $roomids = [];
|
|
|
+ if(!empty($chat_rooms)){
|
|
|
+ foreach ($chat_rooms as $room){$roomids[] = $room['room_id'];}
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $last_msgs = $mod_room->getLastRoomMsgs($roomids);
|
|
|
+
|
|
|
+ $ret = $this->talk_format($last_msgs,'room',$user,$local_last);
|
|
|
|
|
|
return $ret;
|
|
|
}
|
|
@@ -370,46 +385,40 @@ class member_talkControl extends mbMemberControl
|
|
|
|
|
|
foreach($talks as $last_msg)
|
|
|
{
|
|
|
- if($type == 'room')
|
|
|
- {
|
|
|
+ if($type == "room"){
|
|
|
$id = $last_msg['room_id'];
|
|
|
+ }elseif($type=='chatwo'){
|
|
|
+ $id = $last_msg['from_user'] == $user?$last_msg['to_user']:$last_msg['from_user'];
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- if(isset($local_last[$id]) && $local_last[$id]<$last_msg["msg_id"]) {
|
|
|
+
|
|
|
+ if(isset($local_last[$id]) && $local_last[$id]>0) {
|
|
|
+ if($local_last[$id]<$last_msg["msg_id"])
|
|
|
+ {
|
|
|
$not_read = $mod_room->getNotReadCnt($type,$local_last[$id],$last_msg["msg_id"],$id);
|
|
|
- }else{
|
|
|
+ }
|
|
|
+ elseif($local_last[$id] == $last_msg["msg_id"])
|
|
|
+ {
|
|
|
$not_read = 0;
|
|
|
}
|
|
|
-
|
|
|
- $item = [
|
|
|
- "msg_id" => $last_msg['msg_id'],
|
|
|
- "msg" => $last_msg['msg'],
|
|
|
- "add_time" => $last_msg['add_time'],
|
|
|
- "not_read" => $not_read,
|
|
|
- "room_id" => $id
|
|
|
- ];
|
|
|
- }
|
|
|
- elseif($type=='chatwo')
|
|
|
- {
|
|
|
- $id = $last_msg['from_user'] == $user?$last_msg['to_user']:$last_msg['from_user'];
|
|
|
-
|
|
|
- if(isset($local_last[$id]) && $local_last[$id]<$last_msg["msg_id"]) {
|
|
|
- $not_read = $mod_room->getNotReadCnt($type,$local_last[$id],$last_msg["msg_id"],$id);
|
|
|
- }else{
|
|
|
+ else{
|
|
|
$not_read = 0;
|
|
|
}
|
|
|
-
|
|
|
- $item = [
|
|
|
- "msg_id" => $last_msg['msg_id'],
|
|
|
- "msg" => $last_msg['msg'],
|
|
|
- "add_time" => $last_msg['add_time'],
|
|
|
- "not_read" => $not_read,
|
|
|
- "member_id" => $id
|
|
|
- ];
|
|
|
}else{
|
|
|
- $id = 0;
|
|
|
- $item = [];
|
|
|
+ $not_read = 0;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ $item = [
|
|
|
+ "msg_id" => $last_msg['msg_id'],
|
|
|
+ "msg" => $last_msg['msg'],
|
|
|
+ "add_time" => $last_msg['add_time'],
|
|
|
+ "not_read" => $not_read,
|
|
|
+ "item_id" => $id
|
|
|
+ ];
|
|
|
+
|
|
|
$items[$id] = $item;
|
|
|
}
|
|
|
return $items;
|