0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-09 05:29:00 +02:00

modules: Start an m_user module; add preliminary message highlight test.

This commit is contained in:
Jason Volk 2018-09-14 05:08:08 -07:00
parent 45c72304e3
commit 6a646f1ba4
2 changed files with 40 additions and 0 deletions

View file

@ -85,6 +85,7 @@ s_module_LTLIBRARIES = \
m_moduledir = @moduledir@
m_noop_la_SOURCES = m_noop.cc
m_user_la_SOURCES = m_user.cc
m_event_la_SOURCES = m_event.cc
m_typing_la_SOURCES = m_typing.cc
m_receipt_la_SOURCES = m_receipt.cc
@ -99,6 +100,7 @@ m_room_aliases_la_SOURCES = m_room_aliases.cc
m_module_LTLIBRARIES = \
m_noop.la \
m_user.la \
m_event.la \
m_typing.la \
m_receipt.la \

38
modules/m_user.cc Normal file
View file

@ -0,0 +1,38 @@
// 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::m;
using namespace ircd;
mapi::header
IRCD_MODULE
{
"Matrix user library; modular components."
};
extern "C" bool
highlighted_event(const event &event,
const user &user)
{
if(json::get<"type"_>(event) != "m.room.message")
return false;
const json::object &content
{
json::get<"content"_>(event)
};
const string_view &body
{
content.get("body")
};
return has(body, user.user_id);
}