2020-08-23 04:22:41 +02:00
|
|
|
// The Construct
|
2019-09-26 21:16:22 +02:00
|
|
|
//
|
2020-08-23 04:22:41 +02:00
|
|
|
// Copyright (C) The Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
2019-09-26 21:16:22 +02:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
ircd::m::event::id::buf
|
2020-08-23 04:22:41 +02:00
|
|
|
ircd::m::breadcrumbs::set(const json::array &rooms)
|
2019-09-26 21:16:22 +02:00
|
|
|
const
|
|
|
|
{
|
|
|
|
const json::strung object
|
|
|
|
{
|
|
|
|
json::members
|
|
|
|
{
|
|
|
|
{ "rooms", rooms }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-23 04:22:41 +02:00
|
|
|
return account_data.set("im.vector.setting.breadcrumbs", object);
|
2019-09-26 21:16:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2020-08-23 04:22:41 +02:00
|
|
|
ircd::m::breadcrumbs::for_each(const closure_bool &closure)
|
2019-09-26 21:16:22 +02:00
|
|
|
const
|
|
|
|
{
|
|
|
|
bool ret{true};
|
|
|
|
get(std::nothrow, [&closure, &ret]
|
|
|
|
(const json::array &rooms)
|
|
|
|
{
|
2020-08-23 11:36:01 +02:00
|
|
|
for(const json::string room_id : rooms)
|
|
|
|
if(!closure(room_id))
|
2019-09-26 21:16:22 +02:00
|
|
|
{
|
|
|
|
ret = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-08-23 04:22:41 +02:00
|
|
|
ircd::m::breadcrumbs::get(const closure &closure)
|
2019-09-26 21:16:22 +02:00
|
|
|
const
|
|
|
|
{
|
|
|
|
if(!get(std::nothrow, closure))
|
|
|
|
throw m::NOT_FOUND
|
|
|
|
{
|
2020-08-23 04:22:41 +02:00
|
|
|
"User has no breadcrumbs set in their account_data."
|
2019-09-26 21:16:22 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2020-08-23 04:22:41 +02:00
|
|
|
ircd::m::breadcrumbs::get(std::nothrow_t,
|
|
|
|
const closure &closure)
|
2019-09-26 21:16:22 +02:00
|
|
|
const
|
|
|
|
{
|
2020-08-23 04:22:41 +02:00
|
|
|
return account_data.get(std::nothrow, "im.vector.setting.breadcrumbs", [&closure]
|
2019-09-26 21:16:22 +02:00
|
|
|
(const string_view &key, const json::object &object)
|
|
|
|
{
|
|
|
|
const json::array &rooms
|
|
|
|
{
|
|
|
|
object["rooms"]
|
|
|
|
};
|
|
|
|
|
|
|
|
closure(rooms);
|
|
|
|
});
|
|
|
|
}
|