최근 메시지만 전송 받도록 수정.

This commit is contained in:
2018-04-16 08:18:40 +09:00
parent db97400b43
commit bc3a8fefd8
6 changed files with 69 additions and 20 deletions
+16 -3
View File
@@ -105,11 +105,24 @@ class Message
}
public function toArray():array{
if($this->msgType === Message::MSGTYPE_PUBLIC){
$src = $this->src->toArray();
$dest = [];
}
else if($this->msgType === Message::MSGTYPE_NATIONAL || $this->msgType === Message::MSGTYPE_DIPLOMACY){
$src = $this->src->toArray();
$dest = $this->dest->toArray();
}
else{
$src = $this->src->toArray();
$dest = $this->dest->toArray();
}
return [
'id'=>$this->id,
'msgType'=>$this->msgType,
'src'=>($this->src)?($this->src->toArray()):[],
'dest'=>($this->dest)?($this->dest->toArray()):[],
'src'=>$src,
'dest'=>$dest,
'text'=>$this->msg,
'option'=>$this->msgOption,
'time'=>$this->date->format('Y-m-d H:i:s')
@@ -215,7 +228,7 @@ class Message
return array_map(function ($row) {
return static::buildFromArray($row);
}, $db->query('SELECT * FROM `message` WHERE %l %?', $where, $limitSql));
}, $db->query('SELECT * FROM `message` WHERE %l ORDER BY id DESC %? ', $where, $limitSql));
}
protected function sendRaw(int $mailbox):array{
+11
View File
@@ -66,4 +66,15 @@ class MessageTarget extends Target {
'icon'=>$this->icon
];
}
public function toArrayLight() : array{
//TODO: 이걸 꼭 연관 배열로 보낼 이유가 없다.
//TODO: 아이콘도 축약 가능하다.
return [
'name'=>$this->generalName,
'nation'=>$this->nationName,
'color'=>$this->color,
'icon'=>$this->icon
];
}
}