From b27c07b3a24b0e8fce0f06fda4a62758cd1423e8 Mon Sep 17 00:00:00 2001 From: kambizzandi Date: Mon, 7 Mar 2022 10:49:28 +0330 Subject: [PATCH] convert GET user/photo to base64 --- Modules/Account/moduleSrc/ORM/User.cpp | 12 ++---------- Modules/Account/moduleSrc/ORM/User.h | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Modules/Account/moduleSrc/ORM/User.cpp b/Modules/Account/moduleSrc/ORM/User.cpp index d302bb78..93fef950 100644 --- a/Modules/Account/moduleSrc/ORM/User.cpp +++ b/Modules/Account/moduleSrc/ORM/User.cpp @@ -171,7 +171,7 @@ bool User::apiDELETE(DELETE_METHOD_ARGS_IMPL_APICALL) return /*Targoman::API::Query::*/this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL); } -TAPI::RawData_t User::apiGETphoto(TAPI::JWT_t _JWT, quint64 _usrID) +TAPI::Base64Image_t User::apiGETphoto(TAPI::JWT_t _JWT, quint64 _usrID) { quint64 CurrentUserID = clsJWT(_JWT).usrID(); @@ -186,15 +186,7 @@ TAPI::RawData_t User::apiGETphoto(TAPI::JWT_t _JWT, quint64 _usrID) .one() .value(tblUserExtraInfo::ueiPhoto).toString().toLatin1(); - QString Mime = "image/png"; - QByteArray Image; - if (Photo.size() && Photo.startsWith("data:image/")) - { - Mime = Photo.split(';').first().mid(sizeof("data")); - Image = QByteArray::fromBase64(Photo.mid(Photo.indexOf("base64,") + sizeof ("base64,") - 1)); - } - - return TAPI::RawData_t(Image, Mime); + return TAPI::Base64Image_t(Photo); } bool User::apiUPDATEphoto(TAPI::JWT_t _JWT, TAPI::Base64Image_t _image) diff --git a/Modules/Account/moduleSrc/ORM/User.h b/Modules/Account/moduleSrc/ORM/User.h index 0d75aa2a..e723702e 100644 --- a/Modules/Account/moduleSrc/ORM/User.h +++ b/Modules/Account/moduleSrc/ORM/User.h @@ -48,13 +48,13 @@ private slots: bool ORMUPDATE("Update User info by priviledged user") bool ORMDELETE("Delete a User by priviledged user") - TAPI::RawData_t REST_GET( + TAPI::Base64Image_t REST_GET( photo, ( TAPI::JWT_t _JWT, quint64 _usrID ), - "Get user photo as image" + "Get user photo as base64" ) bool REST_UPDATE( photo,