Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add username to daemon #1544

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/api/requests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ DownloadRepoRequest::DownloadRepoRequest(const Account& account,
account.getAbsoluteUrl("api2/repos/" + repo_id + "/download-info/"),
SeafileApiRequest::METHOD_GET,
account.token),
read_only_(read_only)
read_only_(read_only),
account_(account)
{
}

RepoDownloadInfo RepoDownloadInfo::fromDict(QMap<QString, QVariant>& dict,
const QUrl& url_in,
bool read_only)
bool read_only,
const QString& username)
{
RepoDownloadInfo info;
info.repo_version = dict["repo_version"].toInt();
Expand All @@ -181,6 +183,7 @@ RepoDownloadInfo RepoDownloadInfo::fromDict(QMap<QString, QVariant>& dict,
map.insert("is_readonly", read_only ? 1 : 0);
map.insert("server_url", url.toEncoded().data());
map.insert("repo_salt", salt);
map.insert("username", username);

info.more_info = ::mapToJson(map);

Expand All @@ -200,7 +203,7 @@ void DownloadRepoRequest::requestSuccess(QNetworkReply& reply)
QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);
QMap<QString, QVariant> dict = mapFromJSON(json.data(), &error);

RepoDownloadInfo info = RepoDownloadInfo::fromDict(dict, url(), read_only_);
RepoDownloadInfo info = RepoDownloadInfo::fromDict(dict, url(), read_only_, account_.accountInfo.name);

emit success(info);
}
Expand Down Expand Up @@ -243,7 +246,9 @@ CreateRepoRequest::CreateRepoRequest(const Account& account,
const QString& passwd)
: SeafileApiRequest(account.getAbsoluteUrl(kCreateRepoUrl),
SeafileApiRequest::METHOD_POST,
account.token)
account.token),
account_(account)

{
setFormParam(QString("name"), name);
setFormParam(QString("desc"), desc);
Expand Down Expand Up @@ -305,7 +310,7 @@ void CreateRepoRequest::requestSuccess(QNetworkReply& reply)

QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);
QMap<QString, QVariant> dict = mapFromJSON(json.data(), &error);
RepoDownloadInfo info = RepoDownloadInfo::fromDict(dict, url(), false);
RepoDownloadInfo info = RepoDownloadInfo::fromDict(dict, url(), false, account_.accountInfo.name);

emit success(info);
}
Expand Down
5 changes: 4 additions & 1 deletion src/api/requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class RepoDownloadInfo

static RepoDownloadInfo fromDict(QMap<QString, QVariant>& dict,
const QUrl& url,
bool read_only);
bool read_only,
const QString& username);
};

class DownloadRepoRequest : public SeafileApiRequest
Expand All @@ -113,6 +114,7 @@ protected slots:
Q_DISABLE_COPY(DownloadRepoRequest)

bool read_only_;
Account account_;
};

class GetRepoRequest : public SeafileApiRequest
Expand Down Expand Up @@ -171,6 +173,7 @@ protected slots:

private:
Q_DISABLE_COPY(CreateRepoRequest)
Account account_;
};

class CreateSubrepoRequest : public SeafileApiRequest
Expand Down