mirror of
https://github.com/Cronocide/WebMessage.git
synced 2025-01-22 11:18:25 +00:00
why can't notifications be standardized
This commit is contained in:
parent
d2d2bac23f
commit
112090ca5c
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@ node_modules
|
||||
/dist
|
||||
/vender
|
||||
electron-builder.yml
|
||||
src/temp
|
||||
temp
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
|
108
src/App.vue
108
src/App.vue
@ -64,7 +64,6 @@ import Chat from './components/Chat.vue'
|
||||
import Settings from "./components/Settings.vue"
|
||||
import simplebar from 'simplebar-vue'
|
||||
import 'simplebar/dist/simplebar.css'
|
||||
import Notifier from 'node-notifier'
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
@ -251,6 +250,51 @@ export default {
|
||||
} else {
|
||||
setTimeout(this.cacheMessages, 1000)
|
||||
}
|
||||
},
|
||||
sendNotifierNotification (options, messageData, chatData) {
|
||||
let tempDir = path.join(__dirname, '..', 'temp')
|
||||
if (!fs.existsSync(tempDir)) {
|
||||
fs.mkdirSync(tempDir)
|
||||
}
|
||||
|
||||
const download = require('image-downloader')
|
||||
const fileDir = path.join(tempDir, `avatar_${messageData.authorDocid}.jpg`)
|
||||
const dlOptions = {
|
||||
url: `${this.$store.getters.httpURI}/contactimg?docid=${messageData.authorDocid}&auth=${encodeURIComponent(this.$store.state.password)}`,
|
||||
dest: fileDir,
|
||||
agent: new require('https').Agent({ rejectUnauthorized: false })
|
||||
}
|
||||
|
||||
download.image(dlOptions).then((resp) => {
|
||||
options.icon = fileDir
|
||||
if (fs.statSync(fileDir).size == 0) throw Error('Empty image')
|
||||
}).catch(() => {
|
||||
options.icon = __static + '/icon.png'
|
||||
}).finally(() => {
|
||||
if (!this.$store.state.systemSound) this.notifSound.play()
|
||||
|
||||
const NotificationCenter = require('node-notifier').NotificationCenter
|
||||
let Notifier = null
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
Notifier = new NotificationCenter({
|
||||
withFallback: true,
|
||||
customPath: path.join(__dirname, '../terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier')
|
||||
})
|
||||
|
||||
console.log(__dirname)
|
||||
} else {
|
||||
Notifier = require('node-notifier')
|
||||
}
|
||||
|
||||
Notifier.notify(options, (err, action, metadata)=> {
|
||||
if (err) return
|
||||
if (action == 'activate' && chatData && chatData.id) {
|
||||
ipcRenderer.send('show_win')
|
||||
this.$router.push('/message/'+messageData.personId)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
@ -383,34 +427,7 @@ export default {
|
||||
}
|
||||
|
||||
if (document.hasFocus()) return
|
||||
|
||||
let tempDir = path.join(__dirname, 'temp')
|
||||
if (!fs.existsSync(tempDir)) {
|
||||
fs.mkdirSync(tempDir)
|
||||
}
|
||||
|
||||
const download = require('image-downloader')
|
||||
const fileDir = path.join(tempDir, `avatar_${messageData.authorDocid}.jpg`)
|
||||
const dlOptions = {
|
||||
url: `${this.$store.getters.httpURI}/contactimg?docid=${messageData.authorDocid}&auth=${encodeURIComponent(this.$store.state.password)}`,
|
||||
dest: fileDir,
|
||||
agent: new require('https').Agent({ rejectUnauthorized: false })
|
||||
}
|
||||
|
||||
download.image(dlOptions).then((resp) => {
|
||||
notificationOptions.icon = fileDir
|
||||
if (fs.statSync(fileDir).size == 0) throw Error('Empty image')
|
||||
}).catch((err) => {
|
||||
notificationOptions.icon = notificationOptions.icon = __static + '/icon.png'
|
||||
}).finally(() => {
|
||||
if (!this.$store.state.systemSound) this.notifSound.play()
|
||||
Notifier.notify(notificationOptions, (err, resp, metadata)=> {
|
||||
if (chatData && chatData.id) {
|
||||
ipcRenderer.send('show_win')
|
||||
this.$router.push('/message/'+messageData.personId)
|
||||
}
|
||||
})
|
||||
})
|
||||
this.sendNotifierNotification(notificationOptions, messageData, chatData)
|
||||
} else if (messageData.sender != 1) {
|
||||
console.log('Notifications are not supported on this system.')
|
||||
}
|
||||
@ -442,43 +459,16 @@ export default {
|
||||
if (this.lastNotificationGUID == reaction.guid) return
|
||||
if (this.$route.params.id == reaction.personId && document.hasFocus()) return
|
||||
this.lastNotificationGUID = reaction.guid
|
||||
console.log(reaction)
|
||||
|
||||
const notificationOptions = {
|
||||
appID: 'com.sgtaziz.WebMessage',
|
||||
title: reaction.name,
|
||||
title: chatData.author,
|
||||
message: reaction.text.replace(/\u{fffc}/gu, ""),
|
||||
sound: this.$store.state.systemSound
|
||||
}
|
||||
|
||||
if (document.hasFocus()) return
|
||||
|
||||
let tempDir = path.join(__dirname, 'temp')
|
||||
if (!fs.existsSync(tempDir)) {
|
||||
fs.mkdirSync(tempDir)
|
||||
}
|
||||
|
||||
const download = require('image-downloader')
|
||||
const fileDir = path.join(tempDir, `avatar_${reaction.authorDocid}.jpg`)
|
||||
const dlOptions = {
|
||||
url: `${this.$store.getters.httpURI}/contactimg?docid=${reaction.authorDocid}&auth=${encodeURIComponent(this.$store.state.password)}`,
|
||||
dest: fileDir,
|
||||
agent: new require('https').Agent({ rejectUnauthorized: false })
|
||||
}
|
||||
|
||||
download.image(dlOptions).then((resp) => {
|
||||
notificationOptions.icon = fileDir
|
||||
if (fs.statSync(fileDir).size == 0) throw Error('Empty image')
|
||||
}).catch((err) => {
|
||||
notificationOptions.icon = notificationOptions.icon = __static + '/icon.png'
|
||||
}).finally(() => {
|
||||
if (!this.$store.state.systemSound) this.notifSound.play()
|
||||
Notifier.notify(notificationOptions, (err, resp, metadata)=> {
|
||||
if (chatData && chatData.id) {
|
||||
ipcRenderer.send('show_win')
|
||||
this.$router.push('/message/'+reaction.personId)
|
||||
}
|
||||
})
|
||||
})
|
||||
this.sendNotifierNotification(notificationOptions, reaction, chatData)
|
||||
} else if (reactions && reactions.length > 0 && reactions[0].sender != 1) {
|
||||
console.log('Notifications are not supported on this system.')
|
||||
}
|
||||
|
63
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Info.plist
vendored
Normal file
63
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Info.plist
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>16E195</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>terminal-notifier</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Terminal</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.sgtaziz.WebMessage</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>terminal-notifier</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.7.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>17</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>8B62</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>16B2649</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.12</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0810</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>8B62</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.8</string>
|
||||
<key>LSUIElement</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2012-2016 Eloy Durán, Julien Blanchard. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSUserNotificationAlertStyle</key>
|
||||
<string>alert</string>
|
||||
</dict>
|
||||
</plist>
|
BIN
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier
vendored
Normal file
BIN
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier
vendored
Normal file
Binary file not shown.
1
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/PkgInfo
vendored
Normal file
1
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/PkgInfo
vendored
Normal file
@ -0,0 +1 @@
|
||||
APPL????
|
BIN
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/Terminal.icns
vendored
Normal file
BIN
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/Terminal.icns
vendored
Normal file
Binary file not shown.
@ -0,0 +1,29 @@
|
||||
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw9840\paperh8400
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
|
||||
|
||||
\f0\b\fs24 \cf0 Engineering:
|
||||
\b0 \
|
||||
Some people\
|
||||
\
|
||||
|
||||
\b Human Interface Design:
|
||||
\b0 \
|
||||
Some other people\
|
||||
\
|
||||
|
||||
\b Testing:
|
||||
\b0 \
|
||||
Hopefully not nobody\
|
||||
\
|
||||
|
||||
\b Documentation:
|
||||
\b0 \
|
||||
Whoever\
|
||||
\
|
||||
|
||||
\b With special thanks to:
|
||||
\b0 \
|
||||
Mom\
|
||||
}
|
Binary file not shown.
BIN
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib
generated
vendored
Normal file
BIN
terminal-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib
generated
vendored
Normal file
Binary file not shown.
@ -18,7 +18,17 @@ module.exports = {
|
||||
publish: ['github'],
|
||||
snap: {
|
||||
publish: ['github']
|
||||
},
|
||||
extraFiles: [
|
||||
{
|
||||
from: 'node_modules/node-notifier/vendor/',
|
||||
to: 'resources/vendor'
|
||||
},
|
||||
{
|
||||
from: 'vendor/',
|
||||
to: 'resources/terminal-notifier/vendor'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user