Notification sounds

merge-requests/30/head
Bob Mottram 2021-03-22 13:43:20 +00:00
parent f6a07cde76
commit 5ea91d15c2
1 changed files with 36 additions and 15 deletions

View File

@ -210,16 +210,26 @@ def _newDesktopNotifications(actor: str, inboxJson: {},
if notifyJson.get('dmPostId'): if notifyJson.get('dmPostId'):
if notifyJson['dmPostId'] != postJsonObject['id']: if notifyJson['dmPostId'] != postJsonObject['id']:
notifyJson['dmNotify'] = True notifyJson['dmNotify'] = True
notifyJson['dmNotifyChanged'] = True
newDM = True newDM = True
else:
notifyJson['dmNotifyChanged'] = False
notifyJson['dmPostId'] = postJsonObject['id'] notifyJson['dmPostId'] = postJsonObject['id']
if newDM:
break
else: else:
if not newReply: if not newReply:
if not _hasReadPost(actor, postJsonObject['id'], 'replies'): if not _hasReadPost(actor, postJsonObject['id'], 'replies'):
if notifyJson.get('repliesPostId'): if notifyJson.get('repliesPostId'):
if notifyJson['repliesPostId'] != postJsonObject['id']: if notifyJson['repliesPostId'] != postJsonObject['id']:
notifyJson['repliesNotify'] = True notifyJson['repliesNotify'] = True
notifyJson['repliesNotifyChanged'] = True
newReply = True newReply = True
else:
notifyJson['repliesNotifyChanged'] = False
notifyJson['repliesPostId'] = postJsonObject['id'] notifyJson['repliesPostId'] = postJsonObject['id']
if newReply:
break
def _desktopClearScreen() -> None: def _desktopClearScreen() -> None:
@ -1042,18 +1052,19 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
postJsonObject = {} postJsonObject = {}
originalScreenReader = screenreader originalScreenReader = screenreader
soundsDir = 'theme/default/sounds/'
# prevSay = '' # prevSay = ''
# prevCalendar = False # prevCalendar = False
# prevFollow = False # prevFollow = False
# prevLike = '' # prevLike = ''
# prevShare = False # prevShare = False
dmSoundFilename = 'dm.ogg' dmSoundFilename = soundsDir + 'dm.ogg'
replySoundFilename = 'reply.ogg' replySoundFilename = soundsDir + 'reply.ogg'
# calendarSoundFilename = 'calendar.ogg' # calendarSoundFilename = soundsDir + 'calendar.ogg'
# followSoundFilename = 'follow.ogg' # followSoundFilename = soundsDir + 'follow.ogg'
# likeSoundFilename = 'like.ogg' # likeSoundFilename = soundsDir + 'like.ogg'
# shareSoundFilename = 'share.ogg' # shareSoundFilename = soundsDir + 'share.ogg'
# player = 'ffplay' player = 'ffplay'
nameStr = None nameStr = None
gender = None gender = None
messageStr = None messageStr = None
@ -1082,7 +1093,14 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
yourActor = httpPrefix + '://' + domainFull + '/users/' + nickname yourActor = httpPrefix + '://' + domainFull + '/users/' + nickname
notifyJson = {} notifyJson = {
"dmPostId": "Initial",
"dmNotify": False,
"dmNotifyChanged": False,
"repliesPostId": "Initial",
"repliesNotify": False,
"repliesNotifyChanged": False
}
prevTimelineFirstId = '' prevTimelineFirstId = ''
while (1): while (1):
if not pgpKeyUpload: if not pgpKeyUpload:
@ -1117,14 +1135,17 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
if inboxJson: if inboxJson:
_newDesktopNotifications(yourActor, inboxJson, notifyJson) _newDesktopNotifications(yourActor, inboxJson, notifyJson)
if notifyJson.get('dmNotify'): if notifyJson.get('dmNotify'):
_desktopNotification(notificationType, if notifyJson.get('dmNotifyChanged'):
"Epicyon", "New DM " + yourActor + '/dm') _desktopNotification(notificationType,
_playNotificationSound(dmSoundFilename) "Epicyon",
"New DM " + yourActor + '/dm')
_playNotificationSound(dmSoundFilename, player)
if notifyJson.get('repliesNotify'): if notifyJson.get('repliesNotify'):
_desktopNotification(notificationType, if notifyJson.get('repliesNotifyChanged'):
"Epicyon", _desktopNotification(notificationType,
"New reply " + yourActor + '/replies') "Epicyon",
_playNotificationSound(replySoundFilename) "New reply " + yourActor + '/replies')
_playNotificationSound(replySoundFilename, player)
if boxJson: if boxJson:
timelineFirstId = _getFirstItemId(boxJson) timelineFirstId = _getFirstItemId(boxJson)