0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01:00

modules: Start an m_room_message protocol handler stub.

This commit is contained in:
Jason Volk 2018-10-16 11:35:22 -07:00
parent 46154c61c2
commit 1b72722386
2 changed files with 50 additions and 0 deletions

View file

@ -99,6 +99,7 @@ m_room_join_rules_la_SOURCES = m_room_join_rules.cc
m_room_history_visibility_la_SOURCES = m_room_history_visibility.cc
m_room_canonical_alias_la_SOURCES = m_room_canonical_alias.cc
m_room_aliases_la_SOURCES = m_room_aliases.cc
m_room_message_la_SOURCES = m_room_message.cc
m_module_LTLIBRARIES = \
m_noop.la \
@ -114,6 +115,7 @@ m_module_LTLIBRARIES = \
m_room_history_visibility.la \
m_room_canonical_alias.la \
m_room_aliases.la \
m_room_message.la \
###
###############################################################################

48
modules/m_room_message.cc Normal file
View file

@ -0,0 +1,48 @@
// 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;
mapi::header
IRCD_MODULE
{
"Matrix m.room.message"
};
static void
_message_notify(const m::event &event,
m::vm::eval &eval)
{
const auto &body
{
unquote(json::get<"content"_>(event).get("body"))
};
log::info
{
"%s %s said in %s %s :%s%s",
json::get<"origin"_>(event),
json::get<"sender"_>(event),
json::get<"room_id"_>(event),
json::get<"content"_>(event).get("msgtype"),
trunc(body, 128),
size(body) > 128? "..."_sv : string_view{}
};
}
const m::hookfn<m::vm::eval &>
_message_notify_hookfn
{
{
{ "_site", "vm.notify" },
{ "type", "m.room.message" },
},
_message_notify
};