Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2700018
matrix-event.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
matrix-event.cpp
View Options
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2021 Tusooa Zhu <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include
<libkazv-config.hpp>
#include
<immer/config.hpp>
// https://github.com/arximboldi/immer/issues/168
#include
"matrix-event.hpp"
#include
"helper.hpp"
using
namespace
Kazv
;
static
std
::
optional
<
LocalEchoDesc
>
getLocalEcho
(
std
::
variant
<
Event
,
LocalEchoDesc
>
event
)
{
if
(
std
::
holds_alternative
<
LocalEchoDesc
>
(
event
))
{
return
std
::
get
<
LocalEchoDesc
>
(
event
);
}
else
{
return
std
::
nullopt
;
}
}
static
Event
getEvent
(
std
::
variant
<
Event
,
LocalEchoDesc
>
event
)
{
if
(
std
::
holds_alternative
<
LocalEchoDesc
>
(
event
))
{
return
std
::
get
<
LocalEchoDesc
>
(
event
).
event
;
}
else
{
return
std
::
get
<
Event
>
(
event
);
}
}
MatrixEvent
::
MatrixEvent
(
lager
::
reader
<
std
::
variant
<
Event
,
LocalEchoDesc
>>
event
,
QObject
*
parent
)
:
QObject
(
parent
)
,
m_localEcho
(
event
.
map
(
getLocalEcho
))
,
m_event
(
event
.
map
(
getEvent
))
,
LAGER_QT
(
eventId
)(
m_event
.
xform
(
zug
::
map
([](
Event
e
)
{
return
e
.
id
();
})
|
strToQt
))
,
LAGER_QT
(
sender
)(
m_event
.
xform
(
zug
::
map
([](
Event
e
)
{
return
e
.
sender
();
})
|
strToQt
))
,
LAGER_QT
(
type
)(
m_event
.
xform
(
zug
::
map
([](
Event
e
)
{
return
e
.
type
();
})
|
strToQt
))
,
LAGER_QT
(
stateKey
)(
m_event
.
xform
(
zug
::
map
([](
Event
e
)
{
return
e
.
stateKey
();
})
|
strToQt
))
,
LAGER_QT
(
content
)(
m_event
.
xform
(
zug
::
map
([](
Event
e
)
{
return
e
.
content
().
get
().
get
<
QJsonObject
>
();
})))
,
LAGER_QT
(
encrypted
)(
m_event
.
xform
(
zug
::
map
([](
Event
e
)
{
return
e
.
encrypted
();
})))
,
LAGER_QT
(
isState
)(
m_event
.
map
([](
Event
e
)
{
return
e
.
isState
();
}))
,
LAGER_QT
(
unsignedData
)(
m_event
.
map
([](
Event
e
)
{
auto
j
=
e
.
raw
();
if
(
j
.
get
().
contains
(
"unsigned"
))
{
return
j
.
get
()[
"unsigned"
].
template
get
<
QJsonObject
>
();
}
else
{
return
QJsonObject
();
}
}))
,
LAGER_QT
(
isLocalEcho
)(
m_localEcho
.
map
([](
const
auto
&
maybe
)
{
return
maybe
.
has_value
();
}))
,
LAGER_QT
(
isSending
)(
m_localEcho
.
map
([](
const
auto
&
maybe
)
{
return
maybe
.
has_value
()
&&
maybe
.
value
().
status
==
LocalEchoDesc
::
Sending
;
}))
,
LAGER_QT
(
isFailed
)(
m_localEcho
.
map
([](
const
auto
&
maybe
)
{
return
maybe
.
has_value
()
&&
maybe
.
value
().
status
==
LocalEchoDesc
::
Failed
;
}))
,
LAGER_QT
(
txnId
)(
m_localEcho
.
map
([](
const
auto
&
maybe
)
{
return
maybe
.
has_value
()
?
QString
::
fromStdString
(
maybe
.
value
().
txnId
)
:
QStringLiteral
(
""
);
}))
,
LAGER_QT
(
redacted
)(
m_event
.
map
([](
const
auto
&
e
)
{
return
e
.
redacted
();
}))
{
}
MatrixEvent
::~
MatrixEvent
()
=
default
;
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Fri, Jul 18, 12:05 PM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
260348
Default Alt Text
matrix-event.cpp (2 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment