Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
029ae18a
Verified
Commit
029ae18a
authored
4 years ago
by
Loren Burkholder
Committed by
Nicolas Werner
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Format markdown as HTML in notifications
parent
cc3d32c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/notifications/ManagerLinux.cpp
+4
-2
4 additions, 2 deletions
src/notifications/ManagerLinux.cpp
src/notifications/ManagerMac.mm
+4
-2
4 additions, 2 deletions
src/notifications/ManagerMac.mm
src/notifications/ManagerWin.cpp
+4
-2
4 additions, 2 deletions
src/notifications/ManagerWin.cpp
with
12 additions
and
6 deletions
src/notifications/ManagerLinux.cpp
+
4
−
2
View file @
029ae18a
...
...
@@ -13,6 +13,7 @@
#include
"MatrixClient.h"
#include
"Utils.h"
#include
<mtx/responses/notifications.hpp>
#include
<cmark.h>
NotificationsManager
::
NotificationsManager
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
@@ -58,6 +59,7 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
const
auto
sender
=
cache
::
displayName
(
room_id
,
QString
::
fromStdString
(
mtx
::
accessors
::
sender
(
notification
.
event
)));
const
auto
text
=
utils
::
event_body
(
notification
.
event
);
const
auto
formattedText
=
cmark_markdown_to_html
(
text
.
toStdString
().
c_str
(),
text
.
length
(),
CMARK_OPT_UNSAFE
);
QVariantMap
hints
;
hints
[
"image-data"
]
=
icon
;
...
...
@@ -71,9 +73,9 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
// body
if
(
mtx
::
accessors
::
msg_type
(
notification
.
event
)
==
mtx
::
events
::
MessageType
::
Emote
)
argumentList
<<
"* "
+
sender
+
" "
+
t
ext
;
argumentList
<<
"* "
+
sender
+
" "
+
formattedT
ext
;
else
argumentList
<<
sender
+
": "
+
t
ext
;
argumentList
<<
sender
+
": "
+
formattedT
ext
;
// The list of actions has always the action name and then a localized version of that
// action. Currently we just use an empty string for that.
...
...
This diff is collapsed.
Click to expand it.
src/notifications/ManagerMac.mm
+
4
−
2
View file @
029ae18a
...
...
@@ -8,6 +8,7 @@
#include
"MatrixClient.h"
#include
"Utils.h"
#include
<mtx/responses/notifications.hpp>
#include
<cmark.h>
@interface
NSUserNotification
(
CFIPrivate
)
-
(
void
)
set_identityImage
:(
NSImage
*
)
image
;
...
...
@@ -26,15 +27,16 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
const
auto
sender
=
cache
::
displayName
(
QString
::
fromStdString
(
notification
.
room_id
),
QString
::
fromStdString
(
mtx
::
accessors
::
sender
(
notification
.
event
)));
const
auto
text
=
utils
::
event_body
(
notification
.
event
);
const
auto
formattedText
=
cmark_markdown_to_html
(
text
.
toStdString
().
c_str
(),
text
.
length
(),
CMARK_OPT_UNSAFE
);
NSUserNotification
*
notif
=
[[
NSUserNotification
alloc
]
init
];
notif
.
title
=
QString
::
fromStdString
(
cache
::
singleRoomInfo
(
notification
.
room_id
).
name
).
toNSString
();
notif
.
subtitle
=
QString
(
"%1 sent a message"
).
arg
(
sender
).
toNSString
();
if
(
mtx
::
accessors
::
msg_type
(
notification
.
event
)
==
mtx
::
events
::
MessageType
::
Emote
)
notif
.
informativeText
=
QString
(
"* "
).
append
(
sender
).
append
(
" "
).
append
(
t
ext
).
toNSString
();
notif
.
informativeText
=
QString
(
"* "
).
append
(
sender
).
append
(
" "
).
append
(
formattedT
ext
).
toNSString
();
else
notif
.
informativeText
=
t
ext
.
toNSString
();
notif
.
informativeText
=
formattedT
ext
.
toNSString
();
notif
.
soundName
=
NSUserNotificationDefaultSoundName
;
[[
NSUserNotificationCenter
defaultUserNotificationCenter
]
deliverNotification
:
notif
];
...
...
This diff is collapsed.
Click to expand it.
src/notifications/ManagerWin.cpp
+
4
−
2
View file @
029ae18a
...
...
@@ -10,6 +10,7 @@
#include
"MatrixClient.h"
#include
"Utils.h"
#include
<mtx/responses/notifications.hpp>
#include
<cmark.h>
using
namespace
WinToastLib
;
...
...
@@ -53,6 +54,7 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
cache
::
displayName
(
QString
::
fromStdString
(
notification
.
room_id
),
QString
::
fromStdString
(
mtx
::
accessors
::
sender
(
notification
.
event
)));
const
auto
text
=
utils
::
event_body
(
notification
.
event
);
const
auto
formattedText
=
cmark_markdown_to_html
(
text
.
toStdString
().
c_str
(),
text
.
length
(),
CMARK_OPT_UNSAFE
);
if
(
!
isInitialized
)
init
();
...
...
@@ -66,10 +68,10 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
WinToastTemplate
::
FirstLine
);
if
(
mtx
::
accessors
::
msg_type
(
notification
.
event
)
==
mtx
::
events
::
MessageType
::
Emote
)
templ
.
setTextField
(
QString
(
"* "
).
append
(
sender
).
append
(
" "
).
append
(
t
ext
).
toStdWString
(),
QString
(
"* "
).
append
(
sender
).
append
(
" "
).
append
(
formattedT
ext
).
toStdWString
(),
WinToastTemplate
::
SecondLine
);
else
templ
.
setTextField
(
QString
(
"%1"
).
arg
(
t
ext
).
toStdWString
(),
templ
.
setTextField
(
QString
(
"%1"
).
arg
(
formattedT
ext
).
toStdWString
(),
WinToastTemplate
::
SecondLine
);
// TODO: implement room or user avatar
// templ.setImagePath(L"C:/example.png");
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment