Enhance message acknowledgment handling in EncryptionChannelReceive with improved error management
https://github.com/nosial/Socialbox-PHP/issues/16
This commit is contained in:
parent
7165734aef
commit
0ff277ed4c
1 changed files with 49 additions and 42 deletions
|
@ -76,18 +76,30 @@
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
$messages = EncryptionChannelManager::receiveData(
|
$messages = EncryptionChannelManager::receiveData(
|
||||||
$rpcRequest->getParameter('channel_uuid'), $encryptionChannel->determineRecipient($requestingPeer->getAddress(), true)
|
$rpcRequest->getParameter('channel_uuid'), $encryptionChannel->determineRecipient($requestingPeer->getAddress(), true)
|
||||||
);
|
);
|
||||||
$messageUuids = array_map(fn($message) => $message->getUuid(), $messages);
|
}
|
||||||
|
catch(DatabaseOperationException $e)
|
||||||
|
{
|
||||||
|
throw new StandardRpcException('Failed to retrieve the messages', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
if($acknowledge)
|
if($acknowledge)
|
||||||
|
{
|
||||||
|
$messageUuids = array_map(fn($message) => $message->getUuid(), $messages);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
EncryptionChannelManager::acknowledgeMessagesBatch(
|
EncryptionChannelManager::acknowledgeMessagesBatch(
|
||||||
channelUuid: $rpcRequest->getParameter('channel_uuid'),
|
channelUuid: $rpcRequest->getParameter('channel_uuid'),
|
||||||
messageUuids: $messageUuids,
|
messageUuids: $messageUuids,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
catch (DatabaseOperationException $e)
|
||||||
|
{
|
||||||
|
throw new StandardRpcException('Failed to acknowledge the messages locally', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
$externalPeer = $encryptionChannel->getExternalPeer();
|
$externalPeer = $encryptionChannel->getExternalPeer();
|
||||||
if($externalPeer !== null)
|
if($externalPeer !== null)
|
||||||
|
@ -121,11 +133,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(DatabaseOperationException $e)
|
|
||||||
{
|
|
||||||
throw new StandardRpcException('Failed to retrieve the messages', StandardError::INTERNAL_SERVER_ERROR, $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rpcRequest->produceResponse(array_map(fn($message) => $message->toStandard(), $messages));
|
return $rpcRequest->produceResponse(array_map(fn($message) => $message->toStandard(), $messages));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue