Fixes for cache issues.

This commit is contained in:
stephb9959
2021-12-22 21:54:03 -08:00
parent d27441d793
commit e8cf7a6f21
4 changed files with 31 additions and 10 deletions

2
build
View File

@@ -1 +1 @@
121
122

View File

@@ -33,11 +33,11 @@ namespace OpenWifi {
}
return ReturnObject(Answer);
} else {
Types::StringVec IDs = Utils::Split(QB_.Select);
Poco::JSON::Array ArrayObj;
for(auto &i:IDs) {
for(auto &i:SelectedRecords()) {
SecurityObjects::UserInfo UInfo;
if(StorageService()->GetSubUserById(i,UInfo)) {
auto tI{i};
if(StorageService()->GetSubUserById(tI,UInfo)) {
Poco::JSON::Object Obj;
if (IdOnly) {
ArrayObj.add(UInfo.Id);

View File

@@ -32,11 +32,11 @@ namespace OpenWifi {
}
return ReturnObject(Answer);
} else {
Types::StringVec IDs = Utils::Split(QB_.Select);
Poco::JSON::Array ArrayObj;
for(auto &i:IDs) {
for(auto &i:SelectedRecords()) {
SecurityObjects::UserInfo UInfo;
if(StorageService()->GetUserById(i,UInfo)) {
auto tI{i};
if(StorageService()->GetUserById(tI,UInfo)) {
Poco::JSON::Object Obj;
if (IdOnly) {
ArrayObj.add(UInfo.Id);

View File

@@ -1526,7 +1526,8 @@ namespace OpenWifi {
public:
struct QueryBlock {
uint64_t StartDate = 0 , EndDate = 0 , Offset = 0 , Limit = 0, LogType = 0 ;
std::string SerialNumber, Filter, Select;
std::string SerialNumber, Filter;
std::vector<std::string> Select;
bool Lifetime=false, LastOnly=false, Newest=false, CountOnly=false, AdditionalInfo=false;
};
typedef std::map<std::string, std::string> BindingMap;
@@ -1607,7 +1608,7 @@ namespace OpenWifi {
}
inline bool NeedAdditionalInfo() const { return QB_.AdditionalInfo; }
inline const std::string & SelectedRecords() const { return QB_.Select; }
inline const std::vector<std::string> & SelectedRecords() const { return QB_.Select; }
inline const Poco::JSON::Object::Ptr & ParseStream() {
return IncomingParser_.parse(Request->stream()).extract<Poco::JSON::Object::Ptr>();
@@ -1845,6 +1846,22 @@ namespace OpenWifi {
}
}
inline void SendCompressedTarFile(const std::string & FileName, const std::string & Content) {
Response->set("Content-Type","application/gzip");
Response->set("Content-Disposition", "attachment; filename=" + FileName );
Response->set("Content-Transfer-Encoding","binary");
Response->set("Accept-Ranges", "bytes");
Response->set("Cache-Control", "private");
Response->set("Pragma", "private");
Response->set("Expires", "Mon, 26 Jul 2027 05:00:00 GMT");
Response->setStatus(Poco::Net::HTTPResponse::HTTP_OK);
AddCORS();
Response->setContentLength(Content.size());
Response->setChunkedTransferEncoding(true);
std::ostream& OutputStream = Response->send();
OutputStream << Content;
}
inline void SendFile(Poco::File & File, const std::string & UUID) {
Response->set("Content-Type","application/octet-stream");
Response->set("Content-Disposition", "attachment; filename=" + UUID );
@@ -1947,7 +1964,6 @@ namespace OpenWifi {
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 0);
QB_.Limit = GetParameter(RESTAPI::Protocol::LIMIT, 100);
QB_.Filter = GetParameter(RESTAPI::Protocol::FILTER, "");
QB_.Select = GetParameter(RESTAPI::Protocol::SELECT, "");
QB_.Lifetime = GetBoolParameter(RESTAPI::Protocol::LIFETIME,false);
QB_.LogType = GetParameter(RESTAPI::Protocol::LOGTYPE,0);
QB_.LastOnly = GetBoolParameter(RESTAPI::Protocol::LASTONLY,false);
@@ -1955,6 +1971,11 @@ namespace OpenWifi {
QB_.CountOnly = GetBoolParameter(RESTAPI::Protocol::COUNTONLY,false);
QB_.AdditionalInfo = GetBoolParameter(RESTAPI::Protocol::WITHEXTENDEDINFO,false);
auto RawSelect = GetParameter(RESTAPI::Protocol::SELECT, "");
auto Entries = Poco::StringTokenizer(RawSelect,",");
for(const auto &i:Entries)
QB_.Select.emplace_back(i);
if(QB_.Offset<1)
QB_.Offset=0;
return true;