Update image handling for display picture operations
This commit is contained in:
parent
426df31421
commit
746744eb64
2 changed files with 10 additions and 5 deletions
|
@ -40,7 +40,7 @@
|
||||||
return $rpcRequest->produceError(StandardError::RPC_BAD_REQUEST, "Failed to decode JPEG image base64 data");
|
return $rpcRequest->produceError(StandardError::RPC_BAD_REQUEST, "Failed to decode JPEG image base64 data");
|
||||||
}
|
}
|
||||||
|
|
||||||
$sanitizedImage = Utilities::resizeImage(Utilities::sanitizeJpeg($decodedImage), 126, 126);
|
$sanitizedImage = Utilities::resizeImage(Utilities::sanitizeJpeg($decodedImage), 256, 256);
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
|
@ -53,10 +53,7 @@
|
||||||
RegisteredPeerManager::updateDisplayPicture($request->getPeer(), $sanitizedImage);
|
RegisteredPeerManager::updateDisplayPicture($request->getPeer(), $sanitizedImage);
|
||||||
|
|
||||||
// Check & update the session flow
|
// Check & update the session flow
|
||||||
if($request->getSession()->flagExists(SessionFlags::SET_DISPLAY_PICTURE))
|
SessionManager::updateFlow($request->getSession(), [SessionFlags::SET_DISPLAY_PICTURE]);
|
||||||
{
|
|
||||||
SessionManager::updateFlow($request->getSession(), [SessionFlags::SET_DISPLAY_PICTURE]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -471,11 +471,19 @@
|
||||||
|
|
||||||
if($peer->isExternal())
|
if($peer->isExternal())
|
||||||
{
|
{
|
||||||
|
// TODO: Implement this
|
||||||
throw new InvalidArgumentException('Cannot delete the display picture of an external peer');
|
throw new InvalidArgumentException('Cannot delete the display picture of an external peer');
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::getLogger()->verbose(sprintf("Deleting display picture of peer %s", $peer->getUuid()));
|
Logger::getLogger()->verbose(sprintf("Deleting display picture of peer %s", $peer->getUuid()));
|
||||||
|
|
||||||
|
// Delete the file if it exists
|
||||||
|
$displayPicturePath = Configuration::getStorageConfiguration()->getUserDisplayImagesPath() . DIRECTORY_SEPARATOR . $peer->getDisplayPicture() . '.jpeg';
|
||||||
|
if(file_exists($displayPicturePath))
|
||||||
|
{
|
||||||
|
unlink($displayPicturePath);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$statement = Database::getConnection()->prepare('UPDATE `registered_peers` SET display_picture=NULL WHERE uuid=?');
|
$statement = Database::getConnection()->prepare('UPDATE `registered_peers` SET display_picture=NULL WHERE uuid=?');
|
||||||
|
|
Loading…
Add table
Reference in a new issue