2019-02-08 06:04:52 +01:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
#pragma once
|
2020-03-06 04:35:20 +01:00
|
|
|
#define HAVE_IRCD_M_FED_USER_H
|
2019-02-08 06:04:52 +01:00
|
|
|
|
2020-03-06 04:35:20 +01:00
|
|
|
namespace ircd::m::fed::user::keys
|
2019-02-08 06:04:52 +01:00
|
|
|
{
|
|
|
|
struct claim;
|
|
|
|
struct query;
|
|
|
|
}
|
|
|
|
|
2020-03-06 04:35:20 +01:00
|
|
|
struct ircd::m::fed::user::keys::query
|
2020-03-08 02:15:58 +01:00
|
|
|
:request
|
2019-02-08 06:04:52 +01:00
|
|
|
{
|
2020-03-06 04:35:20 +01:00
|
|
|
using opts = fed::user::opts;
|
2019-02-08 06:04:52 +01:00
|
|
|
using devices = vector_view<const string_view>;
|
|
|
|
using user_devices = std::pair<m::user::id, devices>;
|
2019-07-30 21:12:26 +02:00
|
|
|
using users_devices = const vector_view<const user_devices>;
|
|
|
|
using users_devices_map = std::map<m::user::id, json::array>;
|
|
|
|
|
|
|
|
static json::object make_content(const mutable_buffer &, const users_devices &);
|
|
|
|
static json::object make_content(const mutable_buffer &, const users_devices_map &);
|
2019-02-08 06:04:52 +01:00
|
|
|
|
|
|
|
explicit operator json::object() const
|
|
|
|
{
|
2020-03-08 02:15:58 +01:00
|
|
|
return json::object
|
|
|
|
{
|
|
|
|
in.content
|
|
|
|
};
|
2019-02-08 06:04:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
explicit
|
|
|
|
query(const json::object &content,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
2019-07-30 21:12:26 +02:00
|
|
|
query(const users_devices_map &,
|
2019-02-21 23:57:45 +01:00
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
2019-07-30 21:12:26 +02:00
|
|
|
query(const users_devices &,
|
2019-02-08 06:04:52 +01:00
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
|
|
|
query(const user_devices &,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
|
|
|
query(const m::user::id &,
|
|
|
|
const string_view &device_id,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
|
|
|
query(const m::user::id &,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
|
|
|
query() = default;
|
|
|
|
};
|
|
|
|
|
2020-03-06 04:35:20 +01:00
|
|
|
struct ircd::m::fed::user::keys::claim
|
2020-03-08 02:15:58 +01:00
|
|
|
:request
|
2019-02-08 06:04:52 +01:00
|
|
|
{
|
2020-03-06 04:35:20 +01:00
|
|
|
using opts = fed::user::opts;
|
2019-02-08 06:40:32 +01:00
|
|
|
using device = std::pair<string_view, string_view>;
|
|
|
|
using devices = vector_view<const device>;
|
|
|
|
using user_devices = std::pair<m::user::id, devices>;
|
2019-07-30 21:12:26 +02:00
|
|
|
using users_devices = vector_view<const user_devices>;
|
|
|
|
using users_devices_map = std::map<m::user::id, json::object>;
|
|
|
|
|
|
|
|
static json::object make_content(const mutable_buffer &, const users_devices &);
|
|
|
|
static json::object make_content(const mutable_buffer &, const users_devices_map &);
|
2019-02-08 06:04:52 +01:00
|
|
|
|
|
|
|
explicit operator json::object() const
|
|
|
|
{
|
2020-03-08 02:15:58 +01:00
|
|
|
return json::object
|
|
|
|
{
|
|
|
|
in.content
|
|
|
|
};
|
2019-02-08 06:04:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
explicit
|
|
|
|
claim(const json::object &content,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
2019-07-30 21:12:26 +02:00
|
|
|
claim(const users_devices_map &,
|
2019-02-22 01:46:23 +01:00
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
2019-07-30 21:12:26 +02:00
|
|
|
claim(const users_devices &,
|
2019-02-08 06:40:32 +01:00
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
|
|
|
claim(const user_devices &,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
|
|
|
claim(const m::user::id &,
|
|
|
|
const device &device,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
|
|
|
claim(const m::user::id &,
|
|
|
|
const string_view &device_id,
|
|
|
|
const string_view &algorithm,
|
|
|
|
const mutable_buffer &,
|
|
|
|
opts);
|
|
|
|
|
2019-02-08 06:04:52 +01:00
|
|
|
claim() = default;
|
|
|
|
};
|