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
e3002f79
Commit
e3002f79
authored
3 years ago
by
Joe Donofry
Committed by
Nicolas Werner
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix macOS m.image notif crash
parent
a9dde2ef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!14
Fix macOS m.image notif crash
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/notifications/ManagerMac.mm
+34
-7
34 additions, 7 deletions
src/notifications/ManagerMac.mm
with
34 additions
and
7 deletions
src/notifications/ManagerMac.mm
+
34
−
7
View file @
e3002f79
...
...
@@ -7,6 +7,33 @@
#include
<QtMac>
#include
<QImage>
@interface
UNNotificationAttachment
(
UNNotificationAttachmentAdditions
)
+
(
UNNotificationAttachment
*
)
createFromImageData
:(
NSData
*
)
imgData
identifier
:(
NSString
*
)
imageFileIdentifier
options
:(
NSDictionary
*
)
attachmentOptions
;
@end
@implementation
UNNotificationAttachment
(
UNNotificationAttachmentAdditions
)
+
(
UNNotificationAttachment
*
)
createFromImageData
:(
NSData
*
)
imgData
identifier
:(
NSString
*
)
imageFileIdentifier
options
:(
NSDictionary
*
)
attachmentOptions
{
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
NSString
*
tmpSubFolderName
=
[[
NSProcessInfo
processInfo
]
globallyUniqueString
];
NSURL
*
tmpSubFolderURL
=
[
NSURL
fileURLWithPath
:[
NSTemporaryDirectory
()
stringByAppendingPathComponent
:
tmpSubFolderName
]
isDirectory
:
true
];
NSError
*
error
=
nil
;
[
fileManager
createDirectoryAtURL
:
tmpSubFolderURL
withIntermediateDirectories
:
true
attributes
:
nil
error
:&
error
];
if
(
error
)
{
NSLog
(
@"%@"
,[
error
localizedDescription
]);
return
nil
;
}
NSURL
*
fileURL
=
[
tmpSubFolderURL
URLByAppendingPathComponent
:
imageFileIdentifier
];
[
imgData
writeToURL
:
fileURL
atomically
:
true
];
UNNotificationAttachment
*
imageAttachment
=
[
UNNotificationAttachment
attachmentWithIdentifier
:
@""
URL
:
fileURL
options
:
attachmentOptions
error
:&
error
];
if
(
error
)
{
NSLog
(
@"%@"
,[
error
localizedDescription
]);
return
nil
;
}
return
imageAttachment
;
}
@end
NotificationsManager
::
NotificationsManager
(
QObject
*
parent
)
:
QObject
(
parent
)
{
...
...
@@ -42,14 +69,14 @@ NotificationsManager::objCxxPostNotification(const QString &room_name,
content
.
threadIdentifier
=
room_id
.
toNSString
();
if
(
!
bodyImagePath
.
isEmpty
())
{
NSError
*
_Nullable
error
;
NSURL
*
imageURL
=
[
NSURL
URLWithString
:
bodyImagePath
.
toNSString
()];
NSArray
*
attachments
=
[
NSMutableArray
array
];
UNNotificationAttachment
*
attachment
=
[
UNNotificationAttachment
attachmentWithIdentifier
:
@""
URL
:
imageURL
options
:
nil
error
:&
error
];
if
(
error
)
{
NSLog
(
@"%@"
,[
error
localizedDescription
]);
NSURL
*
imageURL
=
[
NSURL
fileURLWithPath
:
bodyImagePath
.
toNSString
()];
NSData
*
img
=
[
NSData
dataWithContentsOfURL
:
imageURL
];
NSArray
*
attachments
=
[
NSMutableArray
array
];
UNNotificationAttachment
*
attachment
=
[
UNNotificationAttachment
createFromImageData
:
img
identifier
:
@"attachment_image.jpeg"
options
:
nil
];
if
(
attachment
)
{
attachments
=
[
NSMutableArray
arrayWithObjects
:
attachment
,
nil
];
content
.
attachments
=
attachments
;
}
content
.
attachments
=
[
attachments
arrayByAddingObject
:
attachment
];
}
UNNotificationRequest
*
notificationRequest
=
[
UNNotificationRequest
requestWithIdentifier
:
event_id
.
toNSString
()
content
:
content
trigger
:
nil
];
...
...
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