2018-02-14 21:54:21 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#include "account.h"
|
|
|
|
|
|
|
|
using namespace ircd;
|
|
|
|
|
2018-03-05 13:21:19 +01:00
|
|
|
extern "C" bool is_active__user(const m::user &user);
|
2018-03-09 18:00:28 +01:00
|
|
|
extern "C" m::event::id::buf activate__user(const m::user &user);
|
|
|
|
extern "C" m::event::id::buf deactivate__user(const m::user &user);
|
2018-03-05 13:21:19 +01:00
|
|
|
|
2018-02-14 21:54:21 +01:00
|
|
|
mapi::header
|
|
|
|
IRCD_MODULE
|
|
|
|
{
|
2018-02-15 22:06:49 +01:00
|
|
|
"Client 3.4,3.5,3.6 :Account"
|
2018-02-14 21:54:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
resource
|
|
|
|
account_resource
|
|
|
|
{
|
|
|
|
"/_matrix/client/r0/account",
|
|
|
|
{
|
2018-02-15 22:06:49 +01:00
|
|
|
"(3.4,3.5,3.6) Account management"
|
2018-02-14 21:54:21 +01:00
|
|
|
}
|
|
|
|
};
|
2018-03-05 12:59:46 +01:00
|
|
|
|
2018-03-05 13:21:19 +01:00
|
|
|
m::event::id::buf
|
2018-03-09 18:00:28 +01:00
|
|
|
activate__user(const m::user &user)
|
2018-03-05 13:21:19 +01:00
|
|
|
{
|
2018-03-09 18:00:28 +01:00
|
|
|
const m::user::room user_room
|
2018-03-05 13:21:19 +01:00
|
|
|
{
|
2018-03-09 18:00:28 +01:00
|
|
|
user
|
2018-03-05 13:21:19 +01:00
|
|
|
};
|
|
|
|
|
2018-03-09 18:00:28 +01:00
|
|
|
return send(user_room, m::me.user_id, "ircd.account", "active",
|
2018-03-05 13:21:19 +01:00
|
|
|
{
|
2018-03-09 18:00:28 +01:00
|
|
|
{ "value", true }
|
|
|
|
});
|
2018-03-05 13:21:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2018-03-05 12:59:46 +01:00
|
|
|
is_active__user(const m::user &user)
|
|
|
|
{
|
2018-03-09 18:00:28 +01:00
|
|
|
const m::user::room user_room
|
|
|
|
{
|
|
|
|
user
|
|
|
|
};
|
|
|
|
|
2018-03-05 12:59:46 +01:00
|
|
|
bool ret{false};
|
2018-03-09 18:00:28 +01:00
|
|
|
user_room.get(std::nothrow, "ircd.account", "active", [&ret]
|
2018-03-05 12:59:46 +01:00
|
|
|
(const m::event &event)
|
|
|
|
{
|
|
|
|
const json::object &content
|
|
|
|
{
|
|
|
|
at<"content"_>(event)
|
|
|
|
};
|
|
|
|
|
2018-03-09 18:00:28 +01:00
|
|
|
ret = content.get<bool>("value") == true;
|
2018-03-05 12:59:46 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|