Fixing disconnection injected twice
This commit is contained in:
parent
b48f8c741d
commit
673e541531
@ -16,7 +16,7 @@ class Db_Member extends Db{
|
|||||||
|
|
||||||
const DB_TABLE = '`*PREFIX*documents_member`';
|
const DB_TABLE = '`*PREFIX*documents_member`';
|
||||||
|
|
||||||
const ACTIVITY_THRESHOLD = 60; // 1 Minute
|
const ACTIVITY_THRESHOLD = 90; // 1.5 Minutes
|
||||||
|
|
||||||
const MEMBER_STATUS_ACTIVE = 1;
|
const MEMBER_STATUS_ACTIVE = 1;
|
||||||
const MEMBER_STATUS_INACTIVE = 2;
|
const MEMBER_STATUS_INACTIVE = 2;
|
||||||
|
@ -85,20 +85,20 @@ class Db_Op extends Db {
|
|||||||
|
|
||||||
public function addMember($esId, $memberId, $fullName, $color, $imageUrl){
|
public function addMember($esId, $memberId, $fullName, $color, $imageUrl){
|
||||||
$op = '{"optype":"AddMember","memberid":"'. $memberId .'","timestamp":"'. time() .'", "setProperties":{"fullName":"'. $fullName .'","color":"'. $color .'","imageUrl":"'. $imageUrl .'"}}';
|
$op = '{"optype":"AddMember","memberid":"'. $memberId .'","timestamp":"'. time() .'", "setProperties":{"fullName":"'. $fullName .'","color":"'. $color .'","imageUrl":"'. $imageUrl .'"}}';
|
||||||
$this->insertOp($esId, $op);
|
$this->insertOp($esId, $memberId, $op);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeCursor($esId, $memberId){
|
public function removeCursor($esId, $memberId){
|
||||||
if ($this->hasOp($esId, $memberId, 'AddCursor')){
|
if ($this->hasOp($esId, $memberId, 'AddCursor') && !$this->hasLastOp($esId, $memberId, 'RemoveCursor')){
|
||||||
$op = '{"optype":"RemoveCursor","memberid":"'. $memberId .'","reason":"server-idle","timestamp":'. time() .'}';
|
$op = '{"optype":"RemoveCursor","memberid":"'. $memberId .'","reason":"server-idle","timestamp":'. time() .'}';
|
||||||
$this->insertOp($esId, $op);
|
$this->insertOp($esId, $memberId, $op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeMember($esId, $memberId){
|
public function removeMember($esId, $memberId){
|
||||||
if ($this->hasOp($esId, $memberId, 'AddMember')){
|
if ($this->hasOp($esId, $memberId, 'AddMember') && !$this->hasLastOp($esId, $memberId, 'RemoveMember')){
|
||||||
$op ='{"optype":"RemoveMember","memberid":"'. $memberId .'","timestamp":'. time() .'}';
|
$op ='{"optype":"RemoveMember","memberid":"'. $memberId .'","timestamp":'. time() .'}';
|
||||||
$this->insertOp($esId, $op);
|
$this->insertOp($esId, $memberId, $op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,18 +106,41 @@ class Db_Op extends Db {
|
|||||||
//TODO: Follow the spec https://github.com/kogmbh/WebODF/blob/master/webodf/lib/ops/OpUpdateMember.js#L95
|
//TODO: Follow the spec https://github.com/kogmbh/WebODF/blob/master/webodf/lib/ops/OpUpdateMember.js#L95
|
||||||
$op = '{"optype":"UpdateMember","memberid":"'. $memberId .'","fullName":"'. $fullName .'","color":"'. $color .'","imageUrl":"'. $imageUrl .'","timestamp":'. time() .'}'
|
$op = '{"optype":"UpdateMember","memberid":"'. $memberId .'","fullName":"'. $fullName .'","color":"'. $color .'","imageUrl":"'. $imageUrl .'","timestamp":'. time() .'}'
|
||||||
;
|
;
|
||||||
$this->insertOp($esId, $op);
|
$this->insertOp($esId, $memberId, $op);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function insertOp($esId, $op){
|
protected function insertOp($esId, $memberId, $op){
|
||||||
$op = new Db_Op(array(
|
$op = new Db_Op(array(
|
||||||
$esId,
|
$esId,
|
||||||
0,
|
$memberId,
|
||||||
$op
|
$op
|
||||||
));
|
));
|
||||||
$op->insert();
|
$op->insert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hasLastOp($esId, $memberId, $opType){
|
||||||
|
$query = \OCP\DB::prepare('
|
||||||
|
SELECT `opspec`
|
||||||
|
FROM ' . self::DB_TABLE . '
|
||||||
|
WHERE `es_id`=?
|
||||||
|
AND `member`=?
|
||||||
|
|
||||||
|
ORDER BY `seq` DESC
|
||||||
|
',
|
||||||
|
2,0
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $query->execute(array($esId, $memberId));
|
||||||
|
$ops = $result->fetchAll();
|
||||||
|
foreach ($ops as $op){
|
||||||
|
$decoded = json_decode($op['opspec'], true);
|
||||||
|
if ($decoded['optype']==$opType){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected function hasOp($esId, $memberId, $opType){
|
protected function hasOp($esId, $memberId, $opType){
|
||||||
$ops = $this->execute(
|
$ops = $this->execute(
|
||||||
'SELECT * FROM ' . $this->tableName . ' WHERE `es_id`=? AND `opspec` LIKE \'%"' . $opType . '","memberid":"' . $memberId .'"%\'',
|
'SELECT * FROM ' . $this->tableName . ' WHERE `es_id`=? AND `opspec` LIKE \'%"' . $opType . '","memberid":"' . $memberId .'"%\'',
|
||||||
|
@ -48,7 +48,7 @@ class File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getByShareToken($token){
|
public static function getByShareToken($token){
|
||||||
$linkItem = \OCP\Share::getShareByToken($token);
|
$linkItem = \OCP\Share::getShareByToken($token, false);
|
||||||
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
|
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
|
||||||
// seems to be a valid share
|
// seems to be a valid share
|
||||||
$rootLinkItem = \OCP\Share::resolveReShare($linkItem);
|
$rootLinkItem = \OCP\Share::resolveReShare($linkItem);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user