0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-11 16:13:01 +01:00
construct/modules/client/account/account.cc

70 lines
1.4 KiB
C++
Raw Normal View History

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;
extern "C" bool is_active__user(const m::user &user);
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-02-14 21:54:21 +01:00
mapi::header
IRCD_MODULE
{
"Client 3.4,3.5,3.6 :Account"
2018-02-14 21:54:21 +01:00
};
resource
account_resource
{
"/_matrix/client/r0/account",
{
"(3.4,3.5,3.6) Account management"
2018-02-14 21:54:21 +01:00
}
};
m::event::id::buf
activate__user(const m::user &user)
{
const m::user::room user_room
{
user
};
2019-06-24 09:25:53 +02:00
return send(user_room, m::me.user_id, "ircd.account", "active", json::members
{
{ "value", true }
});
}
bool
is_active__user(const m::user &user)
{
const m::user::room user_room
{
user
};
bool ret{false};
user_room.get(std::nothrow, "ircd.account", "active", [&ret]
(const m::event &event)
{
const json::object &content
{
at<"content"_>(event)
};
ret = content.get<bool>("value") == true;
});
return ret;
}