fix notifications for people who haven't allowed them.
This commit is contained in:
@@ -12,7 +12,8 @@ import {Mutex} from 'async-mutex'
|
||||
import {
|
||||
NO_PERMISSIONS_REQUIRED,
|
||||
getPermissionStatus,
|
||||
updatePermission
|
||||
updatePermission,
|
||||
showNotification
|
||||
} from './common'
|
||||
|
||||
const {encrypt, decrypt} = nip04
|
||||
@@ -101,44 +102,11 @@ async function handleContentScriptMessage({type, params, host}) {
|
||||
if (allowed === true) {
|
||||
// authorized, proceed
|
||||
releasePromptMutex()
|
||||
browser.notifications
|
||||
.create(undefined, {
|
||||
type: 'basic',
|
||||
title: `${type} allowed for ${host}`,
|
||||
message: JSON.stringify(
|
||||
params?.event
|
||||
? {
|
||||
kind: params.event.kind,
|
||||
content: params.event.content,
|
||||
tags: params.event.tags
|
||||
}
|
||||
: params,
|
||||
null,
|
||||
2
|
||||
),
|
||||
iconUrl: 'icons/48x48.png'
|
||||
})
|
||||
.then(console.log)
|
||||
.catch(console.log)
|
||||
showNotification(host, allowed, type, params)
|
||||
} else if (allowed === false) {
|
||||
// denied, just refuse immediately
|
||||
releasePromptMutex()
|
||||
browser.notifications.create(undefined, {
|
||||
type: 'basic',
|
||||
title: `${type} denied for ${host}`,
|
||||
message: JSON.stringify(
|
||||
params?.event
|
||||
? {
|
||||
kind: params.event.kind,
|
||||
content: params.event.content,
|
||||
tags: params.event.tags
|
||||
}
|
||||
: params,
|
||||
null,
|
||||
2
|
||||
),
|
||||
iconUrl: 'icons/denied48.png'
|
||||
})
|
||||
showNotification(host, allowed, type, params)
|
||||
return {
|
||||
error: 'denied'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user