Update Matrix.API to comply with the current spec

This commit is contained in:
Gergely Polonkai 2017-10-28 07:59:14 +02:00
parent 3c6b0a85bf
commit e77e6473b8
2 changed files with 787 additions and 597 deletions

File diff suppressed because it is too large Load Diff

View File

@ -705,7 +705,7 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
} }
public void public void
delete_pusher(API.Callback? cb, delete_pushrule(API.Callback? cb,
string scope, string scope,
PusherKind kind, PusherKind kind,
string rule_id) string rule_id)
@ -715,7 +715,7 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
} }
public void public void
get_pusher(API.Callback? cb, get_pushrule(API.Callback? cb,
string scope, string scope,
PusherKind kind, PusherKind kind,
string rule_id) string rule_id)
@ -725,7 +725,7 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
} }
public void public void
add_pusher(API.Callback? cb, add_pushrule(API.Callback? cb,
string scope, string scope,
PusherKind kind, PusherKind kind,
string rule_id, string rule_id,
@ -789,7 +789,7 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
} }
public void public void
toggle_pusher(API.Callback? cb, toggle_pushrule(API.Callback? cb,
string scope, string scope,
PusherKind kind, PusherKind kind,
string rule_id, string rule_id,
@ -812,6 +812,15 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
null, null, builder.get_root(), null, false); null, null, builder.get_root(), null, false);
} }
public void
get_pushrules(API.Callback? cb)
throws Matrix.Error
{
_send(cb,
CallType.API, "GET", "pushrules",
null, null, null, null, false);
}
/* Room creation */ /* Room creation */
public void public void
@ -1007,6 +1016,27 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
null, null, builder.get_root(), null, false); null, null, builder.get_root(), null, false);
} }
public void
unban_user(API.Callback? cb,
string room_id,
string user_id)
throws Matrix.Error
{
string path = "rooms/"
+ Soup.URI.encode(room_id, null)
+ "/unban";
var builder = new Json.Builder();
builder.begin_object();
builder.set_member_name("user_id");
builder.add_string_value(user_id);
builder.end_object();
_send(cb, CallType.API, "POST", path, null, null, builder.get_root(), null, false);
}
public void public void
forget_room(API.Callback? cb, forget_room(API.Callback? cb,
string room_id) string room_id)
@ -1092,6 +1122,40 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
null, null, null, null, false); null, null, null, null, false);
} }
public void
join_room_id_or_alias(API.Callback? cb, string room_id_or_alias)
throws Matrix.Error
{
var path = "join/" + Soup.URI.encode(room_id_or_alias, null);
_send(cb, CallType.API, "POST", path,
null, null, null, null, false);
}
public void
kick_user(API.Callback? cb,
string room_id, string user_id, string? reason)
throws Matrix.Error
{
var path = "rooms/" + Soup.URI.encode(room_id, null) + "/kick";
var builder = new Json.Builder();
builder.begin_object();
builder.set_member_name("user_id");
builder.add_string_value(user_id);
if (reason != null) {
builder.set_member_name("reason");
builder.add_string_value(reason);
}
builder.end_object();
_send(cb, CallType.API, "POST", path,
null, null, builder.get_root(), null, false);
}
/* Room participation */ /* Room participation */
public void public void
@ -1537,6 +1601,15 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
null, null, builder.get_root(), null, false); null, null, builder.get_root(), null, false);
} }
public void
logout(API.Callback? cb)
throws Matrix.Error
{
_send(cb,
CallType.API, "POST", "logout",
null, null, null, null, false);
}
/* User data */ /* User data */
public void public void
@ -1789,6 +1862,36 @@ public class Matrix.HTTPAPI : GLib.Object, Matrix.API {
null, null, content, null, false); null, null, content, null, false);
} }
public void
deactivate_account(API.Callback? cb, string? session, string? login_type)
throws Matrix.Error
{
Json.Builder? builder = null;
if (login_type != null) {
builder = new Json.Builder();
builder.begin_object();
builder.set_member_name("auth");
builder.begin_object();
if (session != null) {
builder.set_member_name("session");
builder.add_string_value(session);
}
builder.set_member_name("type");
builder.add_string_value(login_type);
builder.end_object();
builder.end_object();
}
_send(cb, CallType.API, "POST", "account/deactivate",
null, null, (builder != null) ? builder.get_root() : null, null, false);
}
/* VoIP */ /* VoIP */
public void public void