Skip to content

Commit

Permalink
fetch "shared with me" information separately
Browse files Browse the repository at this point in the history
if the parameter `shared_with_me` is set to `"true"` on the shares API
call the response will only include that and not return any other
sharing information.  therefore let's fetch it inside another job (this
is also how the web client does it).

Signed-off-by: Jyrki Gadinger <[email protected]>
  • Loading branch information
nilsding committed Jan 10, 2025
1 parent 745b34c commit fe6439b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/gui/ocssharejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void OcsShareJob::getShares(const QString &path, const QMap<QString, QString> &p

addParam(QString::fromLatin1("path"), path);
addParam(QString::fromLatin1("reshares"), QString("true"));
addParam(QString::fromLatin1("shared_with_me"), QString("true"));

for (auto it = std::cbegin(params); it != std::cend(params); ++it) {
addParam(it.key(), it.value());
Expand Down Expand Up @@ -208,10 +207,13 @@ void OcsShareJob::createShare(const QString &path,
start();
}

void OcsShareJob::getSharedWithMe()
void OcsShareJob::getSharedWithMe(const QString& path)

Check warning on line 210 in src/gui/ocssharejob.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/ocssharejob.cpp:210:19 [readability-convert-member-functions-to-static]

method 'getSharedWithMe' can be made static
{
setVerb("GET");
addParam(QLatin1String("shared_with_me"), QLatin1String("true"));

addParam(QString::fromLatin1("path"), path);
addParam(QString::fromLatin1("shared_with_me"), QString("true"));

start();
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/ocssharejob.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ class OcsShareJob : public OcsJob

/**
* Returns information on the items shared with the current user.
* @param path Path to request shares for (default all shares)
*/
void getSharedWithMe();
void getSharedWithMe(const QString& path = "");

static const QString _pathForSharesRequest;

Expand Down
5 changes: 5 additions & 0 deletions src/gui/sharemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,11 @@ void ShareManager::fetchShares(const QString &path)
connect(job, &OcsShareJob::shareJobFinished, this, &ShareManager::slotSharesFetched);
connect(job, &OcsJob::ocsError, this, &ShareManager::slotOcsError);
job->getShares(path);

auto *sharedWithMeJob = new OcsShareJob(_account);
connect(sharedWithMeJob, &OcsShareJob::shareJobFinished, this, &ShareManager::slotSharesFetched);
connect(sharedWithMeJob, &OcsJob::ocsError, this, &ShareManager::slotOcsError);
sharedWithMeJob->getSharedWithMe(path);
}

void ShareManager::slotSharesFetched(const QJsonDocument &reply)
Expand Down

0 comments on commit fe6439b

Please sign in to comment.