Skip to content

Commit fe6439b

Browse files
committed
fetch "shared with me" information separately
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]>
1 parent 745b34c commit fe6439b

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/gui/ocssharejob.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ void OcsShareJob::getShares(const QString &path, const QMap<QString, QString> &p
3434

3535
addParam(QString::fromLatin1("path"), path);
3636
addParam(QString::fromLatin1("reshares"), QString("true"));
37-
addParam(QString::fromLatin1("shared_with_me"), QString("true"));
3837

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

211-
void OcsShareJob::getSharedWithMe()
210+
void OcsShareJob::getSharedWithMe(const QString& path)
212211
{
213212
setVerb("GET");
214-
addParam(QLatin1String("shared_with_me"), QLatin1String("true"));
213+
214+
addParam(QString::fromLatin1("path"), path);
215+
addParam(QString::fromLatin1("shared_with_me"), QString("true"));
216+
215217
start();
216218
}
217219

src/gui/ocssharejob.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ class OcsShareJob : public OcsJob
135135

136136
/**
137137
* Returns information on the items shared with the current user.
138+
* @param path Path to request shares for (default all shares)
138139
*/
139-
void getSharedWithMe();
140+
void getSharedWithMe(const QString& path = "");
140141

141142
static const QString _pathForSharesRequest;
142143

src/gui/sharemanager.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,11 @@ void ShareManager::fetchShares(const QString &path)
540540
connect(job, &OcsShareJob::shareJobFinished, this, &ShareManager::slotSharesFetched);
541541
connect(job, &OcsJob::ocsError, this, &ShareManager::slotOcsError);
542542
job->getShares(path);
543+
544+
auto *sharedWithMeJob = new OcsShareJob(_account);
545+
connect(sharedWithMeJob, &OcsShareJob::shareJobFinished, this, &ShareManager::slotSharesFetched);
546+
connect(sharedWithMeJob, &OcsJob::ocsError, this, &ShareManager::slotOcsError);
547+
sharedWithMeJob->getSharedWithMe(path);
543548
}
544549

545550
void ShareManager::slotSharesFetched(const QJsonDocument &reply)

0 commit comments

Comments
 (0)