Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F21908562
notification-handler.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
notification-handler.cpp
View Options
/*
* This file is part of libkazv.
* SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include
<libkazv-config.hpp>
#include
<lager/lenses/at.hpp>
#include
<lager/lenses/attr.hpp>
#include
"notification-handler.hpp"
namespace
Kazv
{
struct
NotificationHandler
::
Private
{
Private
(
lager
::
reader
<
ClientModel
>
clientArg
)
:
client
(
clientArg
)
,
pushRulesDesc
(
clientArg
[
&
ClientModel
::
accountData
]
[
"m.push_rules"
]
[
lager
::
lenses
::
or_default
]
.
map
([](
const
Event
&
event
)
{
return
PushRulesDesc
(
event
);
})
)
{}
lager
::
reader
<
ClientModel
>
client
;
lager
::
reader
<
PushRulesDesc
>
pushRulesDesc
;
};
NotificationHandler
::
NotificationHandler
(
lager
::
reader
<
ClientModel
>
client
)
:
m_d
(
new
Private
(
client
))
{
}
NotificationHandler
::~
NotificationHandler
()
=
default
;
KAZV_DEFINE_COPYABLE_UNIQUE_PTR
(
NotificationHandler
,
m_d
)
PushAction
NotificationHandler
::
handleNotification
(
const
Event
&
e
)
const
{
auto
roomId
=
e
.
raw
().
get
().
contains
(
"room_id"
)
?
e
.
raw
().
get
()[
"room_id"
].
template
get
<
std
::
string
>
()
:
std
::
string
();
auto
room
=
m_d
->
client
[
&
ClientModel
::
roomList
][
&
RoomListModel
::
rooms
][
roomId
][
lager
::
lenses
::
or_default
].
make
().
get
();
return
m_d
->
pushRulesDesc
.
get
().
handle
(
e
,
room
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Dec 28, 1:43 AM (7 m, 3 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
690968
Default Alt Text
notification-handler.cpp (1 KB)
Attached To
Mode
rL libkazv
Attached
Detach File
Event Timeline
Log In to Comment