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

Matrix 1.10 #736

Merged
merged 3 commits into from
Apr 16, 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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ if (API_GENERATION_ENABLED)
gtad/data.h.mustache
gtad/operation.h.mustache
gtad/operation.cpp.mustache
gtad/preamble.mustache
gtad/define_models.mustache
${API_DEFS}
VERBATIM
)
Expand Down
2 changes: 2 additions & 0 deletions Quotient/csapi/admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ class QUOTIENT_API GetWhoIsJob : public BaseJob {
struct ConnectionInfo {
//! Most recently seen IP address of the session.
QString ip{};

//! Unix timestamp that the session was last active.
Omittable<qint64> lastSeen{};

//! User agent string last seen in the session.
QString userAgent{};
};
Expand Down
6 changes: 6 additions & 0 deletions Quotient/csapi/administrative_contact.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ class QUOTIENT_API GetAccount3PIDsJob : public BaseJob {
struct ThirdPartyIdentifier {
//! The medium of the third-party identifier.
QString medium;

//! The third-party identifier address.
QString address;

//! The timestamp, in milliseconds, when the identifier was
//! validated by the identity server.
qint64 validatedAt;

//! The timestamp, in milliseconds, when the homeserver associated the third-party
//! identifier with the user.
qint64 addedAt;
Expand Down Expand Up @@ -87,12 +90,15 @@ class QUOTIENT_API Post3PIDsJob : public BaseJob {
struct ThreePidCredentials {
//! The client secret used in the session with the identity server.
QString clientSecret;

//! The identity server to use.
QString idServer;

//! An access token previously registered with the identity server. Servers
//! can treat this as optional to distinguish between r0.5-compatible clients
//! and this specification version.
QString idAccessToken;

//! The session identifier given by the identity server.
QString sid;
};
Expand Down
2 changes: 2 additions & 0 deletions Quotient/csapi/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob {
struct RoomVersionsCapability {
//! The default room version the server is using for new rooms.
QString defaultVersion;

//! A detailed description of the room versions the server supports.
QHash<QString, QString> available;
};
Expand All @@ -33,6 +34,7 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob {
struct Capabilities {
//! Capability to indicate if the user can change their password.
Omittable<ChangePasswordCapability> changePassword{};

//! The room versions the server supports.
Omittable<RoomVersionsCapability> roomVersions{};

Expand Down
7 changes: 3 additions & 4 deletions Quotient/csapi/content-repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId,
qint64 timeoutMs, bool allowRedirect)
: BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"),
makePath("/_matrix", "/media/v3/download/", serverName, "/", mediaId),
queryToGetContent(allowRemote, timeoutMs, allowRedirect), {}, false)
queryToGetContent(allowRemote, timeoutMs, allowRedirect))
{
setExpectedContentTypes({ "application/octet-stream" });
}
Expand Down Expand Up @@ -104,7 +104,7 @@ GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName,
qint64 timeoutMs, bool allowRedirect)
: BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"),
makePath("/_matrix", "/media/v3/download/", serverName, "/", mediaId, "/", fileName),
queryToGetContentOverrideName(allowRemote, timeoutMs, allowRedirect), {}, false)
queryToGetContentOverrideName(allowRemote, timeoutMs, allowRedirect))
{
setExpectedContentTypes({ "application/octet-stream" });
}
Expand Down Expand Up @@ -139,8 +139,7 @@ GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const
: BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"),
makePath("/_matrix", "/media/v3/thumbnail/", serverName, "/", mediaId),
queryToGetContentThumbnail(width, height, method, allowRemote, timeoutMs,
allowRedirect),
{}, false)
allowRedirect))
{
setExpectedContentTypes({ "image/jpeg", "image/png" });
}
Expand Down
5 changes: 5 additions & 0 deletions Quotient/csapi/create_room.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,27 @@ class QUOTIENT_API CreateRoomJob : public BaseJob {
//! The hostname+port of the identity server which should be used for third-party identifier
//! lookups.
QString idServer;

//! An access token previously registered with the identity server. Servers
//! can treat this as optional to distinguish between r0.5-compatible clients
//! and this specification version.
QString idAccessToken;

//! The kind of address being passed in the address field, for example `email`
//! (see [the list of recognised values](/appendices/#3pid-types)).
QString medium;

//! The invitee's third-party identifier.
QString address;
};

struct StateEvent {
//! The type of event to send.
QString type;

//! The content of the event.
QJsonObject content;

//! The state_key of the state event. Defaults to an empty string.
QString stateKey{};
};
Expand Down
10 changes: 5 additions & 5 deletions Quotient/csapi/definitions/public_rooms_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ struct PublicRoomsChunk {
//! The URL for the room's avatar, if one is set.
QUrl avatarUrl{};

//! The `type` of room (from [`m.room.create`](/client-server-api/#mroomcreate)), if any.
QString roomType{};

//! The room's join rule. When not present, the room is assumed to
//! be `public`. Note that rooms with `invite` join rules are not
//! expected here, but rooms with `knock` rules are given their
//! near-public nature.
QString joinRule{};

//! The `type` of room (from [`m.room.create`](/client-server-api/#mroomcreate)), if any.
QString roomType{};
};

template <>
Expand All @@ -55,8 +55,8 @@ struct JsonObjectConverter<PublicRoomsChunk> {
addParam<IfNotEmpty>(jo, QStringLiteral("name"), pod.name);
addParam<IfNotEmpty>(jo, QStringLiteral("topic"), pod.topic);
addParam<IfNotEmpty>(jo, QStringLiteral("avatar_url"), pod.avatarUrl);
addParam<IfNotEmpty>(jo, QStringLiteral("room_type"), pod.roomType);
addParam<IfNotEmpty>(jo, QStringLiteral("join_rule"), pod.joinRule);
addParam<IfNotEmpty>(jo, QStringLiteral("room_type"), pod.roomType);
}
static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod)
{
Expand All @@ -68,8 +68,8 @@ struct JsonObjectConverter<PublicRoomsChunk> {
fillFromJson(jo.value("name"_ls), pod.name);
fillFromJson(jo.value("topic"_ls), pod.topic);
fillFromJson(jo.value("avatar_url"_ls), pod.avatarUrl);
fillFromJson(jo.value("room_type"_ls), pod.roomType);
fillFromJson(jo.value("join_rule"_ls), pod.joinRule);
fillFromJson(jo.value("room_type"_ls), pod.roomType);
}
};

Expand Down
37 changes: 33 additions & 4 deletions Quotient/csapi/definitions/request_email_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,34 @@
#pragma once

#include <Quotient/converters.h>
#include <Quotient/identity/definitions/request_email_validation.h>

namespace Quotient {

struct EmailValidationData : RequestEmailValidation {
struct EmailValidationData {
//! A unique string generated by the client, and used to identify the
//! validation attempt. It must be a string consisting of the characters
//! `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it
//! must not be empty.
QString clientSecret;

//! The email address to validate.
QString email;

//! The server will only send an email if the `send_attempt`
//! is a number greater than the most recent one which it has seen,
//! scoped to that `email` + `client_secret` pair. This is to
//! avoid repeatedly sending the same email in the case of request
//! retries between the POSTing user and the identity server.
//! The client should increment this value if they desire a new
//! email (e.g. a reminder) to be sent. If they do not, the server
//! should respond with success but not resend the email.
int sendAttempt;

//! Optional. When the validation is completed, the identity server will
//! redirect the user to this URL. This option is ignored when submitting
//! 3PID validation information through a POST request.
QString nextLink{};

//! The hostname of the identity server to communicate with. May optionally
//! include a port. This parameter is ignored when the homeserver handles
//! 3PID verification.
Expand All @@ -28,13 +51,19 @@ template <>
struct JsonObjectConverter<EmailValidationData> {
static void dumpTo(QJsonObject& jo, const EmailValidationData& pod)
{
fillJson<RequestEmailValidation>(jo, pod);
addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret);
addParam<>(jo, QStringLiteral("email"), pod.email);
addParam<>(jo, QStringLiteral("send_attempt"), pod.sendAttempt);
addParam<IfNotEmpty>(jo, QStringLiteral("next_link"), pod.nextLink);
addParam<IfNotEmpty>(jo, QStringLiteral("id_server"), pod.idServer);
addParam<IfNotEmpty>(jo, QStringLiteral("id_access_token"), pod.idAccessToken);
}
static void fillFrom(const QJsonObject& jo, EmailValidationData& pod)
{
fillFromJson<RequestEmailValidation>(jo, pod);
fillFromJson(jo.value("client_secret"_ls), pod.clientSecret);
fillFromJson(jo.value("email"_ls), pod.email);
fillFromJson(jo.value("send_attempt"_ls), pod.sendAttempt);
fillFromJson(jo.value("next_link"_ls), pod.nextLink);
fillFromJson(jo.value("id_server"_ls), pod.idServer);
fillFromJson(jo.value("id_access_token"_ls), pod.idAccessToken);
}
Expand Down
42 changes: 38 additions & 4 deletions Quotient/csapi/definitions/request_msisdn_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,37 @@
#pragma once

#include <Quotient/converters.h>
#include <Quotient/identity/definitions/request_msisdn_validation.h>

namespace Quotient {

struct MsisdnValidationData : RequestMsisdnValidation {
struct MsisdnValidationData {
//! A unique string generated by the client, and used to identify the
//! validation attempt. It must be a string consisting of the characters
//! `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it
//! must not be empty.
QString clientSecret;

//! The two-letter uppercase ISO-3166-1 alpha-2 country code that the
//! number in `phone_number` should be parsed as if it were dialled from.
QString country;

//! The phone number to validate.
QString phoneNumber;

//! The server will only send an SMS if the `send_attempt` is a
//! number greater than the most recent one which it has seen,
//! scoped to that `country` + `phone_number` + `client_secret`
//! triple. This is to avoid repeatedly sending the same SMS in
//! the case of request retries between the POSTing user and the
//! identity server. The client should increment this value if
//! they desire a new SMS (e.g. a reminder) to be sent.
int sendAttempt;

//! Optional. When the validation is completed, the identity server will
//! redirect the user to this URL. This option is ignored when submitting
//! 3PID validation information through a POST request.
QString nextLink{};

//! The hostname of the identity server to communicate with. May optionally
//! include a port. This parameter is ignored when the homeserver handles
//! 3PID verification.
Expand All @@ -28,13 +54,21 @@ template <>
struct JsonObjectConverter<MsisdnValidationData> {
static void dumpTo(QJsonObject& jo, const MsisdnValidationData& pod)
{
fillJson<RequestMsisdnValidation>(jo, pod);
addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret);
addParam<>(jo, QStringLiteral("country"), pod.country);
addParam<>(jo, QStringLiteral("phone_number"), pod.phoneNumber);
addParam<>(jo, QStringLiteral("send_attempt"), pod.sendAttempt);
addParam<IfNotEmpty>(jo, QStringLiteral("next_link"), pod.nextLink);
addParam<IfNotEmpty>(jo, QStringLiteral("id_server"), pod.idServer);
addParam<IfNotEmpty>(jo, QStringLiteral("id_access_token"), pod.idAccessToken);
}
static void fillFrom(const QJsonObject& jo, MsisdnValidationData& pod)
{
fillFromJson<RequestMsisdnValidation>(jo, pod);
fillFromJson(jo.value("client_secret"_ls), pod.clientSecret);
fillFromJson(jo.value("country"_ls), pod.country);
fillFromJson(jo.value("phone_number"_ls), pod.phoneNumber);
fillFromJson(jo.value("send_attempt"_ls), pod.sendAttempt);
fillFromJson(jo.value("next_link"_ls), pod.nextLink);
fillFromJson(jo.value("id_server"_ls), pod.idServer);
fillFromJson(jo.value("id_access_token"_ls), pod.idAccessToken);
}
Expand Down
1 change: 1 addition & 0 deletions Quotient/csapi/list_public_rooms.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class QUOTIENT_API QueryPublicRoomsJob : public BaseJob {
//! An optional string to search for in the room metadata, e.g. name,
//! topic, canonical alias, etc.
QString genericSearchTerm{};

//! An optional list of [room types](/client-server-api/#types) to search
//! for. To include rooms without a room type, specify `null` within this
//! list. When not specified, all applicable rooms (regardless of type)
Expand Down
1 change: 1 addition & 0 deletions Quotient/csapi/login.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class QUOTIENT_API GetLoginFlowsJob : public BaseJob {
//! The login type. This is supplied as the `type` when
//! logging in.
QString type;

//! If `type` is `m.login.token`, an optional field to indicate
//! to the unauthenticated client that the homeserver supports
//! the [`POST /login/get_token`](/client-server-api/#post_matrixclientv1loginget_token)
Expand Down
5 changes: 5 additions & 0 deletions Quotient/csapi/notifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ class QUOTIENT_API GetNotificationsJob : public BaseJob {
//! The action(s) to perform when the conditions for this rule are met.
//! See [Push Rules: API](/client-server-api/#push-rules-api).
QVector<QVariant> actions;

//! The Event object for the event that triggered the notification.
EventPtr event;

//! Indicates whether the user has sent a read receipt indicating
//! that they have read this message.
bool read;

//! The ID of the room in which the event was posted.
QString roomId;

//! The unix timestamp at which the event notification was sent,
//! in milliseconds.
qint64 ts;

//! The profile tag of the rule that matched this event.
QString profileTag{};
};
Expand Down
9 changes: 9 additions & 0 deletions Quotient/csapi/pusher.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class QUOTIENT_API GetPushersJob : public BaseJob {
//! Required if `kind` is `http`. The URL to use to send
//! notifications to.
QUrl url{};

//! The format to use when sending notifications to the Push
//! Gateway.
QString format{};
Expand All @@ -29,24 +30,31 @@ class QUOTIENT_API GetPushersJob : public BaseJob {
//! more detail.
//! Max length, 512 bytes.
QString pushkey;

//! The kind of pusher. `"http"` is a pusher that
//! sends HTTP pokes.
QString kind;

//! This is a reverse-DNS style identifier for the application.
//! Max length, 64 chars.
QString appId;

//! A string that will allow the user to identify what application
//! owns this pusher.
QString appDisplayName;

//! A string that will allow the user to identify what device owns
//! this pusher.
QString deviceDisplayName;

//! The preferred language for receiving notifications (e.g. 'en'
//! or 'en-US')
QString lang;

//! A dictionary of information for the pusher implementation
//! itself.
PusherData data;

//! This string determines which set of device specific rules this
//! pusher executes.
QString profileTag{};
Expand Down Expand Up @@ -115,6 +123,7 @@ class QUOTIENT_API PostPusherJob : public BaseJob {
//! notifications to. MUST be an HTTPS URL with a path of
//! `/_matrix/push/v1/notify`.
QUrl url{};

//! The format to send notifications in to Push Gateways if the
//! `kind` is `http`. The details about what fields the
//! homeserver should send to the push gateway are defined in the
Expand Down
3 changes: 2 additions & 1 deletion Quotient/csapi/registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob(
}

DeactivateAccountJob::DeactivateAccountJob(const Omittable<AuthenticationData>& auth,
const QString& idServer)
const QString& idServer, Omittable<bool> erase)
: BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"),
makePath("/_matrix/client/v3", "/account/deactivate"))
{
QJsonObject _dataJson;
addParam<IfNotEmpty>(_dataJson, QStringLiteral("auth"), auth);
addParam<IfNotEmpty>(_dataJson, QStringLiteral("id_server"), idServer);
addParam<IfNotEmpty>(_dataJson, QStringLiteral("erase"), erase);
setRequestData({ _dataJson });
addExpectedKey("id_server_unbind_result");
}
Expand Down
Loading
Loading