mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-05-13 17:34:10 +02:00
Merge pull request #2686 from nextcloud/add-email-sharing
Added sharing via email.
This commit is contained in:
commit
14105d4ec6
@ -38,10 +38,14 @@ QString Sharee::format() const
|
||||
|
||||
if (_type == Type::Group) {
|
||||
formatted += QLatin1String(" (group)");
|
||||
} else if (_type == Type::Email) {
|
||||
formatted += QLatin1String(" (email)");
|
||||
} else if (_type == Type::Federated) {
|
||||
formatted += QLatin1String(" (remote)");
|
||||
} else if (_type == Type::Circle) {
|
||||
formatted += QLatin1String(" (circle)");
|
||||
} else if (_type == Type::Room) {
|
||||
formatted += QLatin1String(" (conversation)");
|
||||
}
|
||||
|
||||
return formatted;
|
||||
@ -81,59 +85,22 @@ void ShareeModel::fetch(const QString &search, const ShareeSet &blacklist)
|
||||
|
||||
void ShareeModel::shareesFetched(const QJsonDocument &reply)
|
||||
{
|
||||
auto data = reply.object().value("ocs").toObject().value("data").toObject();
|
||||
|
||||
QVector<QSharedPointer<Sharee>> newSharees;
|
||||
|
||||
/*
|
||||
* Todo properly loop all of this
|
||||
*/
|
||||
auto exact = data.value("exact").toObject();
|
||||
{
|
||||
auto users = exact.value("users").toArray();
|
||||
foreach (auto user, users) {
|
||||
newSharees.append(parseSharee(user.toObject()));
|
||||
}
|
||||
const QStringList shareeTypes {"users", "groups", "emails", "remotes", "circles", "rooms"};
|
||||
|
||||
auto groups = exact.value("groups").toArray();
|
||||
foreach (auto group, groups) {
|
||||
newSharees.append(parseSharee(group.toObject()));
|
||||
}
|
||||
const auto appendSharees = [this, &shareeTypes](const QJsonObject &data, QVector<QSharedPointer<Sharee>>& out) {
|
||||
for (const auto &shareeType : shareeTypes) {
|
||||
const auto category = data.value(shareeType).toArray();
|
||||
for (const auto &sharee : category) {
|
||||
out.append(parseSharee(sharee.toObject()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto remotes = exact.value("remotes").toArray();
|
||||
foreach (auto remote, remotes) {
|
||||
newSharees.append(parseSharee(remote.toObject()));
|
||||
}
|
||||
|
||||
auto circles = exact.value("circles").toArray();
|
||||
foreach (auto circle, circles) {
|
||||
newSharees.append(parseSharee(circle.toObject()));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto users = data.value("users").toArray();
|
||||
foreach (auto user, users) {
|
||||
newSharees.append(parseSharee(user.toObject()));
|
||||
}
|
||||
}
|
||||
{
|
||||
auto groups = data.value("groups").toArray();
|
||||
foreach (auto group, groups) {
|
||||
newSharees.append(parseSharee(group.toObject()));
|
||||
}
|
||||
}
|
||||
{
|
||||
auto remotes = data.value("remotes").toArray();
|
||||
foreach (auto remote, remotes) {
|
||||
newSharees.append(parseSharee(remote.toObject()));
|
||||
}
|
||||
}
|
||||
{
|
||||
auto circles = data.value("circles").toArray();
|
||||
foreach (auto circle, circles) {
|
||||
newSharees.append(parseSharee(circle.toObject()));
|
||||
}
|
||||
appendSharees(reply.object().value("ocs").toObject().value("data").toObject(), newSharees);
|
||||
appendSharees(reply.object().value("ocs").toObject().value("data").toObject().value("exact").toObject(), newSharees);
|
||||
}
|
||||
|
||||
// Filter sharees that we have already shared with
|
||||
|
@ -40,8 +40,10 @@ public:
|
||||
enum Type {
|
||||
User = 0,
|
||||
Group = 1,
|
||||
Email = 4,
|
||||
Federated = 6,
|
||||
Circle = 7
|
||||
Circle = 7,
|
||||
Room = 10
|
||||
};
|
||||
|
||||
explicit Sharee(const QString shareWith,
|
||||
|
@ -44,8 +44,10 @@ public:
|
||||
TypeUser = Sharee::User,
|
||||
TypeGroup = Sharee::Group,
|
||||
TypeLink = 3,
|
||||
TypeEmail = Sharee::Email,
|
||||
TypeRemote = Sharee::Federated,
|
||||
TypeCircle = Sharee::Circle
|
||||
TypeCircle = Sharee::Circle,
|
||||
TypeRoom = Sharee::Room
|
||||
};
|
||||
|
||||
using Permissions = SharePermissions;
|
||||
|
Loading…
Reference in New Issue
Block a user