From 12bed2d87bc1e12cd3773a4f4cef0a75be35c84d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 10 Sep 2020 12:15:22 -0700 Subject: [PATCH] ircd::m::room: Add json::tuple for m.room.message schema; property names. --- include/ircd/m/name.h | 5 +++++ include/ircd/m/room/message.h | 38 +++++++++++++++++++++++++++++++++++ include/ircd/m/room/room.h | 2 ++ matrix/name.cc | 5 +++++ 4 files changed, 50 insertions(+) create mode 100644 include/ircd/m/room/message.h diff --git a/include/ircd/m/name.h b/include/ircd/m/name.h index b437e3e59..7fb7b9144 100644 --- a/include/ircd/m/name.h +++ b/include/ircd/m/name.h @@ -204,4 +204,9 @@ struct ircd::m::name static constexpr const char *const profile_tag {"profile_tag"}; static constexpr const char *const lang {"lang"}; static constexpr const char *const append {"append"}; + + static constexpr const char *const body {"body"}; + static constexpr const char *const msgtype {"msgtype"}; + static constexpr const char *const format {"format"}; + static constexpr const char *const formatted_body {"formatted_body"}; }; diff --git a/include/ircd/m/room/message.h b/include/ircd/m/room/message.h new file mode 100644 index 000000000..14a7d4de7 --- /dev/null +++ b/include/ircd/m/room/message.h @@ -0,0 +1,38 @@ +// The Construct +// +// Copyright (C) The Construct Developers, Authors & Contributors +// Copyright (C) 2016-2020 Jason Volk +// +// 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. + +#pragma once +#define HAVE_IRCD_M_ROOM_MESSAGE_H + +/// This is a json::tuple describing the common m.room.message content schema +/// intended for fast and convenient observation of message content. Note that +/// more properties will likely exist and they can be accessed using the +/// json::tuple.source member which points to the json::object this tuple +/// was constructed with. +/// +struct ircd::m::room::message +:json::tuple +< + /// Required. The body of the message. + json::property, + + /// Required. enum. + json::property, + + /// The format used in the formatted_body. + json::property, + + /// The formatted version of the body. This is required if format + /// is specified. + json::property +> +{ + using super_type::tuple; +}; diff --git a/include/ircd/m/room/room.h b/include/ircd/m/room/room.h index 83dc15ac6..a319d6ae1 100644 --- a/include/ircd/m/room/room.h +++ b/include/ircd/m/room/room.h @@ -121,6 +121,7 @@ struct ircd::m::room struct aliases; struct stats; struct server_acl; + struct message; struct bootstrap; using id = m::id::room; @@ -198,6 +199,7 @@ struct ircd::m::room #include "aliases.h" #include "stats.h" #include "server_acl.h" +#include "message.h" #include "bootstrap.h" inline diff --git a/matrix/name.cc b/matrix/name.cc index 708d9d866..d6d5c3e93 100644 --- a/matrix/name.cc +++ b/matrix/name.cc @@ -183,3 +183,8 @@ constexpr const char *const ircd::m::name::app_display_name; constexpr const char *const ircd::m::name::profile_tag; constexpr const char *const ircd::m::name::lang; constexpr const char *const ircd::m::name::append; + +constexpr const char *const ircd::m::name::body; +constexpr const char *const ircd::m::name::msgtype; +constexpr const char *const ircd::m::name::format; +constexpr const char *const ircd::m::name::formatted_body;