yet another sketch
This commit is contained in:
parent
48f8c3551e
commit
1711c9663d
@ -70,9 +70,14 @@ try{
|
|||||||
|
|
||||||
$currentHead = OCA\Office\Op::getHeadSeq($esId);
|
$currentHead = OCA\Office\Op::getHeadSeq($esId);
|
||||||
|
|
||||||
//if $postobject['args']['seq_head'] is the most recent op in the ops-table:
|
if (is_null($seqHead) && is_null($currentHead)) { // very first ops
|
||||||
// append all ops in $postobject['args']['client_ops'] to the ops-table
|
foreach ($ops as $op) {
|
||||||
if ($seqHead > $currentHead){
|
$op['opspec'] = json_encode($op['opspec']);
|
||||||
|
$lastSeq = OCA\Office\Op::add($op);
|
||||||
|
}
|
||||||
|
$response["result"] = 'added';
|
||||||
|
$response["headSeq"] = $lastSeq + 1;
|
||||||
|
} else if ($seqHead === $currentHead) { // no conflict
|
||||||
foreach ($ops as $op){
|
foreach ($ops as $op){
|
||||||
$op['opspec'] = json_encode($op['opspec']);
|
$op['opspec'] = json_encode($op['opspec']);
|
||||||
try{
|
try{
|
||||||
@ -81,6 +86,8 @@ try{
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$response["result"] = 'added';
|
||||||
|
$response["headSeq"] = $lastSeq + 1;
|
||||||
} else {
|
} else {
|
||||||
// result: 'conflict',
|
// result: 'conflict',
|
||||||
// ops: a list of all ops since $postobject['args']['seq_head']
|
// ops: a list of all ops since $postobject['args']['seq_head']
|
||||||
@ -123,4 +130,4 @@ class BadRequestException extends Exception {
|
|||||||
public function getBody(){
|
public function getBody(){
|
||||||
return $this->body;
|
return $this->body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user