Use configfilemanager to get the real command
All checks were successful
Build / build (push) Successful in 11s
All checks were successful
Build / build (push) Successful in 11s
This commit is contained in:
@@ -1,24 +1,27 @@
|
||||
#include "usermanager.h"
|
||||
|
||||
std::vector<std::string> splitString(const std::string& str, char delimiter = '|')
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
std::stringstream ss(str);
|
||||
std::string token;
|
||||
|
||||
while (std::getline(ss, token, delimiter)) {
|
||||
ret.push_back(token);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string userManager::getScanCommandFromUser(const std::string &user)
|
||||
std::string userManager::getScanCommandFromUser(const std::string &user, configfilemanager &cfm)
|
||||
{
|
||||
std::string contname = cfm.at("NEXTCLOUD_CONTAINER_NAME");
|
||||
std::string baseCommand;
|
||||
std::string userCommand;
|
||||
|
||||
if (user.find("__groupfolder") != std::string::npos)
|
||||
{
|
||||
return std::string(SCAN_CMD_GRP) + splitString(user, '/').back();
|
||||
baseCommand = SCAN_CMD_GRP;
|
||||
userCommand = splitString(user, '/').back();
|
||||
}
|
||||
else
|
||||
{
|
||||
baseCommand = SCAN_CMD_USR;
|
||||
userCommand = user;
|
||||
}
|
||||
|
||||
return std::string(SCAN_CMD_USR) + user;
|
||||
size_t pos = 0;
|
||||
while ((pos = baseCommand.find("%1%", pos)) != std::string::npos) {
|
||||
baseCommand.replace(pos, contname.length(), contname);
|
||||
pos += contname.length(); // Move past the replacement
|
||||
}
|
||||
|
||||
return baseCommand + userCommand;
|
||||
}
|
||||
Reference in New Issue
Block a user