mirror of
https://github.com/matrix-construct/construct
synced 2025-02-17 01:00:10 +01:00
modules: Add m_typing eval stub.
This commit is contained in:
parent
4670fdbd1b
commit
51fe770d74
2 changed files with 80 additions and 0 deletions
|
@ -60,10 +60,12 @@ s_module_LTLIBRARIES = \
|
||||||
m_moduledir = @moduledir@
|
m_moduledir = @moduledir@
|
||||||
|
|
||||||
m_noop_la_SOURCES = m_noop.cc
|
m_noop_la_SOURCES = m_noop.cc
|
||||||
|
m_typing_la_SOURCES = m_typing.cc
|
||||||
m_presence_la_SOURCES = m_presence.cc
|
m_presence_la_SOURCES = m_presence.cc
|
||||||
|
|
||||||
m_module_LTLIBRARIES = \
|
m_module_LTLIBRARIES = \
|
||||||
m_noop.la \
|
m_noop.la \
|
||||||
|
m_typing.la \
|
||||||
m_presence.la \
|
m_presence.la \
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
78
modules/m_typing.cc
Normal file
78
modules/m_typing.cc
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
// 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 Typing"
|
||||||
|
};
|
||||||
|
|
||||||
|
static void _handle_edu_m_typing(const m::event &, const m::edu::m_typing &edu);
|
||||||
|
static void handle_edu_m_typing(const m::event &);
|
||||||
|
|
||||||
|
const m::hook
|
||||||
|
_m_typing_eval
|
||||||
|
{
|
||||||
|
handle_edu_m_typing,
|
||||||
|
{
|
||||||
|
{ "_site", "vm.eval" },
|
||||||
|
{ "type", "m.typing" },
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
handle_edu_m_typing(const m::event &event)
|
||||||
|
{
|
||||||
|
const json::object &content
|
||||||
|
{
|
||||||
|
at<"content"_>(event)
|
||||||
|
};
|
||||||
|
|
||||||
|
_handle_edu_m_typing(event, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_handle_edu_m_typing(const m::event &event,
|
||||||
|
const m::edu::m_typing &edu)
|
||||||
|
{
|
||||||
|
const m::room::id &room_id
|
||||||
|
{
|
||||||
|
at<"room_id"_>(edu)
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::user::id &user_id
|
||||||
|
{
|
||||||
|
at<"user_id"_>(edu)
|
||||||
|
};
|
||||||
|
|
||||||
|
if(user_id.host() != at<"origin"_>(event))
|
||||||
|
{
|
||||||
|
log::warning
|
||||||
|
{
|
||||||
|
"Ignoring %s from %s for user %s",
|
||||||
|
at<"type"_>(event),
|
||||||
|
at<"origin"_>(event),
|
||||||
|
string_view{user_id}
|
||||||
|
};
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log::debug
|
||||||
|
{
|
||||||
|
"%s | %s %s typing in %s",
|
||||||
|
at<"origin"_>(event),
|
||||||
|
string_view{user_id},
|
||||||
|
json::get<"typing"_>(edu)? "started"_sv : "stopped"_sv,
|
||||||
|
string_view{room_id}
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue