Prechádzať zdrojové kódy

add leave kickout plain msg

stanley-king 6 rokov pred
rodič
commit
6c7481956b

+ 2 - 0
helper/room/base_room.php

@@ -191,6 +191,7 @@ abstract class base_room
 
     public function change()
     {
+        $this->clear();
         $mod_room = Model('room');
         $item = $mod_room->getRoom($this->room_id());
         if(empty($item)) return false;
@@ -201,6 +202,7 @@ abstract class base_room
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function leave($userid)
     {
+        $this->clear();
         $ret = $this->find($userid);
         if($ret != false) {
             unset($this->mParticipants[$userid]);

+ 40 - 30
helper/room/room_processor.php

@@ -178,30 +178,6 @@ class room_processor implements IProcessor
         return $this->error(errcode::ErrRoomInvite);
     }
 
-    private function factory_change($input)
-    {
-        $roomid = intval($input['room']);
-        if ($roomid <= 0) {
-            return $this->error(errcode::ErrRoomParam);
-        }
-
-        $room = $this->room($roomid);
-        if ($room != false)
-        {
-            $result = $room->change();
-            if ($result != false) {
-                $this->broad_access(msg_builder::change_push($roomid, $room->room_info()));
-                return $this->success($result);
-            }
-        }
-
-        return $this->error(errcode::ErrRoomChange);
-    }
-
-    /**
-     * @param $input
-     * @return mixed|string
-     */
     private function factory_leave($input)
     {
         $roomid = intval($input['room']);
@@ -214,8 +190,17 @@ class room_processor implements IProcessor
             $userid = intval($input['user']);
             if ($userid > 0) {
                 $result = $room->leave($userid);
-                if ($result != false) {
+                if ($result != false)
+                {
                     $this->broad_access(msg_builder::leave_message($roomid, $room->room_type(), $userid));
+                    $this->reply_roomsg($bufid,$room);
+                    $this->broadcast_roomsg($room);
+
+                    $user_count = $room->usercount();
+                    if($user_count >= 0 && $user_count < 10) {
+                        QueueClient::push("OnUpdateRoom",['room_id' => $roomid]);
+                    }
+
                     return $this->success($result);
                 }
             }
@@ -240,8 +225,16 @@ class room_processor implements IProcessor
             if ($user > 0)
             {
                 $result = $room->kickout($user,$kicks);
-                if ($result != false) {
+                if ($result != false)
+                {
                     $this->broad_access(msg_builder::leave_message($roomid, $room->room_type(), $result));
+                    $this->reply_roomsg($bufid,$room);
+                    $this->broadcast_roomsg($room);
+
+                    $user_count = $room->usercount();
+                    if($user_count >= 0 && $user_count < 10) {
+                        QueueClient::push("OnUpdateRoom",['room_id' => $roomid]);
+                    }
                     return $this->success($result);
                 }
             }
@@ -249,10 +242,27 @@ class room_processor implements IProcessor
 
         return $this->error(errcode::ErrRoomLeave);
     }
-    /**
-     * @param $input
-     * @return mixed|string
-     */
+
+    private function factory_change($input)
+    {
+        $roomid = intval($input['room']);
+        if ($roomid <= 0) {
+            return $this->error(errcode::ErrRoomParam);
+        }
+
+        $room = $this->room($roomid);
+        if ($room != false)
+        {
+            $result = $room->change();
+            if ($result != false) {
+                $this->broad_access(msg_builder::change_push($roomid, $room->room_info()));
+                return $this->success($result);
+            }
+        }
+
+        return $this->error(errcode::ErrRoomChange);
+    }
+
     private function factory_push($input)
     {
         $content = $input['content'];

+ 0 - 4
helper/room/util.php

@@ -352,10 +352,6 @@ class talks_helper
         $info = new room_info($room);
         $room_info = $info->format();
 
-        //todo delete test data
-        $default_avatar = "http://pp.myapp.com/ma_icon/0/icon_42287263_1532071055/96";
-        $room_info["avatar"] = $room_info["avatar"] ? $room_info["avatar"] : $default_avatar;
-
         return $room_info;
     }
 }