-
Notifications
You must be signed in to change notification settings - Fork 60
Add support for profile fields (MSC4133) #869
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,18 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob { | |
QHash<QString, QString> available; | ||
}; | ||
|
||
//! The profile fields the server supports and if they can be edited. | ||
struct QUOTIENT_API ProfileFieldsCapability { | ||
//! If the user is allowed to change their own profile fields. | ||
bool enabled; | ||
|
||
//! A list of allowed profile field keys. | ||
QList<QString> allowed; | ||
|
||
//! A list of disallowed profile field keys. | ||
QList<QString> disallowed; | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The contents of |
||
//! The custom capabilities the server supports, using the | ||
//! Java package naming convention. | ||
struct QUOTIENT_API Capabilities { | ||
|
@@ -62,6 +74,10 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob { | |
//! account. | ||
std::optional<BooleanCapability> getLoginToken{}; | ||
|
||
//! Capability to indicate if the user can edit profile fields and which ones they can | ||
//! change. | ||
std::optional<ProfileFieldsCapability> profileFields{}; | ||
|
||
//! Application-dependent keys using the | ||
//! [Common Namespaced Identifier | ||
//! Grammar](/appendices/#common-namespaced-identifier-grammar). | ||
|
@@ -96,6 +112,16 @@ struct QUOTIENT_API JsonObjectConverter<GetCapabilitiesJob::RoomVersionsCapabili | |
} | ||
}; | ||
|
||
template <> | ||
struct QUOTIENT_API JsonObjectConverter<GetCapabilitiesJob::ProfileFieldsCapability> { | ||
static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::ProfileFieldsCapability& result) | ||
{ | ||
fillFromJson(jo.value("enabled"_L1), result.enabled); | ||
fillFromJson(jo.value("allowed"_L1), result.allowed); | ||
fillFromJson(jo.value("disallowed"_L1), result.disallowed); | ||
} | ||
}; | ||
|
||
template <> | ||
struct QUOTIENT_API JsonObjectConverter<GetCapabilitiesJob::Capabilities> { | ||
static void fillFrom(QJsonObject jo, GetCapabilitiesJob::Capabilities& result) | ||
|
@@ -106,6 +132,7 @@ struct QUOTIENT_API JsonObjectConverter<GetCapabilitiesJob::Capabilities> { | |
fillFromJson(jo.take("m.set_avatar_url"_L1), result.setAvatarUrl); | ||
fillFromJson(jo.take("m.3pid_changes"_L1), result.thirdPartyIdChanges); | ||
fillFromJson(jo.take("m.get_login_token"_L1), result.getLoginToken); | ||
fillFromJson(jo.take("uk.tcpip.msc4133.profile_fields"_L1), result.profileFields); | ||
fromJson(jo, result.additionalProperties); | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.