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:
parent
45c72304e3
commit
6a646f1ba4
|
@ -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
38
modules/m_user.cc
Normal 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);
|
||||
}
|
Loading…
Reference in a new issue