2018-03-29 04:54:12 +02: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.
|
|
|
|
|
|
|
|
using namespace ircd;
|
|
|
|
|
2018-04-03 22:12:04 +02:00
|
|
|
mapi::header
|
|
|
|
IRCD_MODULE
|
|
|
|
{
|
|
|
|
"Matrix m.room.member"
|
|
|
|
};
|
|
|
|
|
2018-04-13 23:54:11 +02:00
|
|
|
static void
|
|
|
|
affect_user_room(const m::event &event)
|
|
|
|
{
|
|
|
|
const auto &room_id
|
|
|
|
{
|
|
|
|
at<"room_id"_>(event)
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto &sender
|
|
|
|
{
|
|
|
|
at<"sender"_>(event)
|
|
|
|
};
|
|
|
|
|
|
|
|
const m::user::id &subject
|
|
|
|
{
|
|
|
|
at<"state_key"_>(event)
|
|
|
|
};
|
|
|
|
|
|
|
|
//TODO: ABA / TXN
|
|
|
|
if(!exists(subject))
|
|
|
|
create(subject);
|
|
|
|
|
|
|
|
//TODO: ABA / TXN
|
|
|
|
m::user::room user_room{subject};
|
|
|
|
send(user_room, sender, "ircd.member", room_id, at<"content"_>(event));
|
|
|
|
}
|
|
|
|
|
2018-05-27 07:05:56 +02:00
|
|
|
const m::hookfn<>
|
2018-04-13 23:54:11 +02:00
|
|
|
affect_user_room_hookfn
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ "_site", "vm.notify" },
|
|
|
|
{ "type", "m.room.member" },
|
|
|
|
},
|
|
|
|
affect_user_room
|
|
|
|
};
|
|
|
|
|
2018-03-29 04:54:12 +02:00
|
|
|
static void
|
2018-09-14 04:11:40 +02:00
|
|
|
_can_join_room(const m::event &event,
|
|
|
|
m::vm::eval &eval)
|
2018-03-29 04:54:12 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-14 04:11:40 +02:00
|
|
|
const m::hookfn<m::vm::eval &>
|
2018-03-29 04:54:12 +02:00
|
|
|
_can_join_room_hookfn
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ "_site", "vm.commit" },
|
|
|
|
{ "type", "m.room.member" },
|
|
|
|
{ "membership", "join" },
|
|
|
|
},
|
|
|
|
_can_join_room
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_join_room(const m::event &event)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-05-27 07:05:56 +02:00
|
|
|
const m::hookfn<>
|
2018-03-29 04:54:12 +02:00
|
|
|
_join_room_hookfn
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ "_site", "vm.notify" },
|
|
|
|
{ "type", "m.room.member" },
|
|
|
|
{ "membership", "join" },
|
|
|
|
},
|
|
|
|
_join_room
|
|
|
|
};
|
2018-04-03 21:59:44 +02:00
|
|
|
|
|
|
|
using invite_foreign_proto = m::event::id::buf (const m::event &);
|
2018-09-14 16:39:11 +02:00
|
|
|
mods::import<invite_foreign_proto>
|
2018-04-03 21:59:44 +02:00
|
|
|
invite__foreign
|
|
|
|
{
|
|
|
|
"client_rooms", "invite__foreign"
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2018-09-14 04:11:40 +02:00
|
|
|
invite_foreign(const m::event &event,
|
|
|
|
m::vm::eval &eval)
|
2018-04-03 21:59:44 +02:00
|
|
|
{
|
|
|
|
const m::room::id &room_id
|
|
|
|
{
|
|
|
|
at<"room_id"_>(event)
|
|
|
|
};
|
|
|
|
|
|
|
|
const m::user::id &target
|
|
|
|
{
|
|
|
|
at<"state_key"_>(event)
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto target_host
|
|
|
|
{
|
|
|
|
target.host()
|
|
|
|
};
|
|
|
|
|
|
|
|
const m::room::origins origins
|
|
|
|
{
|
|
|
|
room_id
|
|
|
|
};
|
|
|
|
|
|
|
|
if(origins.has(target_host))
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto eid
|
|
|
|
{
|
|
|
|
invite__foreign(event)
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-14 04:11:40 +02:00
|
|
|
const m::hookfn<m::vm::eval &>
|
2018-04-03 21:59:44 +02:00
|
|
|
invite_foreign_hookfn
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ "_site", "vm.commit" },
|
|
|
|
{ "type", "m.room.member" },
|
|
|
|
{ "membership", "invite" },
|
|
|
|
},
|
|
|
|
invite_foreign
|
|
|
|
};
|