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
98b2fee7
Verified
Commit
98b2fee7
authored
4 years ago
by
Loren Burkholder
Committed by
Nicolas Werner
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Block notifications until the image has been downloaded
parent
64dd10a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/notifications/Manager.cpp
+21
-9
21 additions, 9 deletions
src/notifications/Manager.cpp
with
21 additions
and
9 deletions
src/notifications/Manager.cpp
+
21
−
9
View file @
98b2fee7
...
...
@@ -22,17 +22,22 @@ NotificationsManager::cacheImage(const mtx::events::collections::TimelineEvents
QString
path
{
QStandardPaths
::
writableLocation
(
QStandardPaths
::
CacheLocation
)
+
"/"
+
filename
};
bool
downloadComplete
=
false
;
http
::
client
()
->
download
(
url
,
[
&
path
,
url
,
encryptionInfo
](
const
std
::
string
&
data
,
const
std
::
string
&
,
const
std
::
string
&
,
mtx
::
http
::
RequestErr
err
)
{
[
&
downloadComplete
,
&
path
,
url
,
encryptionInfo
](
const
std
::
string
&
data
,
const
std
::
string
&
,
const
std
::
string
&
,
mtx
::
http
::
RequestErr
err
)
{
if
(
err
)
{
nhlog
::
net
()
->
warn
(
"failed to retrieve image {}: {} {}"
,
url
,
err
->
matrix_error
.
error
,
static_cast
<
int
>
(
err
->
status_code
));
// the image doesn't exist, so delete the path
path
.
clear
();
downloadComplete
=
true
;
return
;
}
...
...
@@ -44,8 +49,11 @@ NotificationsManager::cacheImage(const mtx::events::collections::TimelineEvents
QFile
file
{
path
};
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
path
.
clear
();
downloadComplete
=
true
;
return
;
}
// delete any existing file content
file
.
resize
(
0
);
...
...
@@ -53,10 +61,10 @@ NotificationsManager::cacheImage(const mtx::events::collections::TimelineEvents
// resize the image
QImage
img
{
utils
::
readImage
(
QByteArray
{
temp
.
data
()})};
if
(
img
.
isNull
())
{
path
.
clear
()
;
return
;
if
(
img
.
isNull
())
{
path
.
clear
();
downloadComplete
=
true
;
return
;
}
#ifdef NHEKO_DBUS_SYS // the images in D-Bus notifications are to be 200x100 max
...
...
@@ -68,11 +76,15 @@ NotificationsManager::cacheImage(const mtx::events::collections::TimelineEvents
file
.
close
();
downloadComplete
=
true
;
return
;
}
catch
(
const
std
::
exception
&
e
)
{
nhlog
::
ui
()
->
warn
(
"Error while caching file to: {}"
,
e
.
what
());
}
});
while
(
!
downloadComplete
)
continue
;
return
path
.
toHtmlEscaped
();
}
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