forked from indymedia/epicyon
Highlight button when a new reply arrives
parent
e6c2fc11a3
commit
d26610b6da
16
inbox.py
16
inbox.py
|
@ -45,6 +45,7 @@ from httpsig import messageContentDigest
|
||||||
from blocking import isBlockedDomain
|
from blocking import isBlockedDomain
|
||||||
from posts import downloadAnnounce
|
from posts import downloadAnnounce
|
||||||
from posts import isDM
|
from posts import isDM
|
||||||
|
from posts import isReply
|
||||||
|
|
||||||
def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
|
def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
|
||||||
"""Checks whether files were correctly saved to the inbox
|
"""Checks whether files were correctly saved to the inbox
|
||||||
|
@ -1230,6 +1231,17 @@ def dmNotify(baseDir: str,handle: str) -> None:
|
||||||
with open(dmFile, 'w') as fp:
|
with open(dmFile, 'w') as fp:
|
||||||
fp.write('\n')
|
fp.write('\n')
|
||||||
|
|
||||||
|
def replyNotify(baseDir: str,handle: str) -> None:
|
||||||
|
"""Creates a notification that a new reply has arrived
|
||||||
|
"""
|
||||||
|
accountDir=baseDir+'/accounts/'+handle
|
||||||
|
if not os.path.isdir(accountDir):
|
||||||
|
return
|
||||||
|
replyFile=accountDir+'/.newReply'
|
||||||
|
if not os.path.isfile(replyFile):
|
||||||
|
with open(replyFile, 'w') as fp:
|
||||||
|
fp.write('\n')
|
||||||
|
|
||||||
def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
|
def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
|
||||||
baseDir: str,httpPrefix: str,sendThreads: [], \
|
baseDir: str,httpPrefix: str,sendThreads: [], \
|
||||||
postLog: [],cachedWebfingers: {},personCache: {}, \
|
postLog: [],cachedWebfingers: {},personCache: {}, \
|
||||||
|
@ -1322,6 +1334,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
|
||||||
if validPostContent(messageJson['post'],maxMentions):
|
if validPostContent(messageJson['post'],maxMentions):
|
||||||
if isDM(messageJson['post']):
|
if isDM(messageJson['post']):
|
||||||
dmNotify(baseDir,handle)
|
dmNotify(baseDir,handle)
|
||||||
|
if isReply(messageJson['post'],actor):
|
||||||
|
replyNotify(baseDir,handle)
|
||||||
obtainAvatarForReplyPost(session,baseDir,httpPrefix,domain,personCache,messageJson['post'],debug)
|
obtainAvatarForReplyPost(session,baseDir,httpPrefix,domain,personCache,messageJson['post'],debug)
|
||||||
try:
|
try:
|
||||||
with open(destinationFilename, 'w+') as fp:
|
with open(destinationFilename, 'w+') as fp:
|
||||||
|
@ -1332,6 +1346,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
|
||||||
if validPostContent(messageJson,maxMentions):
|
if validPostContent(messageJson,maxMentions):
|
||||||
if isDM(messageJson):
|
if isDM(messageJson):
|
||||||
dmNotify(baseDir,handle)
|
dmNotify(baseDir,handle)
|
||||||
|
if isReply(messageJson,actor):
|
||||||
|
replyNotify(baseDir,handle)
|
||||||
obtainAvatarForReplyPost(session,baseDir,httpPrefix,domain,personCache,messageJson,debug)
|
obtainAvatarForReplyPost(session,baseDir,httpPrefix,domain,personCache,messageJson,debug)
|
||||||
try:
|
try:
|
||||||
with open(destinationFilename, 'w+') as fp:
|
with open(destinationFilename, 'w+') as fp:
|
||||||
|
|
|
@ -2032,12 +2032,21 @@ def htmlTimeline(translate: {},pageNumber: int, \
|
||||||
"""
|
"""
|
||||||
# should the DM button be highlighted?
|
# should the DM button be highlighted?
|
||||||
newDM=False
|
newDM=False
|
||||||
dmFile=baseDir+'/accounts/'+nickname+'@'+domain+'/.newDM'
|
accountDir=baseDir+'/accounts/'+nickname+'@'+domain
|
||||||
|
dmFile=accountDir+'/.newDM'
|
||||||
if os.path.isfile(dmFile):
|
if os.path.isfile(dmFile):
|
||||||
newDM=True
|
newDM=True
|
||||||
if boxName=='dm':
|
if boxName=='dm':
|
||||||
os.remove(dmFile)
|
os.remove(dmFile)
|
||||||
|
|
||||||
|
# should the Replies button be highlighted?
|
||||||
|
newReply=False
|
||||||
|
replyFile=accountDir+'/.newReply'
|
||||||
|
if os.path.isfile(replyFile):
|
||||||
|
newReply=True
|
||||||
|
if boxName=='tlreplies':
|
||||||
|
os.remove(replyFile)
|
||||||
|
|
||||||
iconsDir=getIconsDir(baseDir)
|
iconsDir=getIconsDir(baseDir)
|
||||||
cssFilename=baseDir+'/epicyon-profile.css'
|
cssFilename=baseDir+'/epicyon-profile.css'
|
||||||
if os.path.isfile(baseDir+'/epicyon.css'):
|
if os.path.isfile(baseDir+'/epicyon.css'):
|
||||||
|
@ -2054,6 +2063,8 @@ def htmlTimeline(translate: {},pageNumber: int, \
|
||||||
if newDM:
|
if newDM:
|
||||||
dmButton='buttonhighlighted'
|
dmButton='buttonhighlighted'
|
||||||
repliesButton='button'
|
repliesButton='button'
|
||||||
|
if newReply:
|
||||||
|
repliesButton='buttonhighlighted'
|
||||||
mediaButton='button'
|
mediaButton='button'
|
||||||
sentButton='button'
|
sentButton='button'
|
||||||
moderationButton='button'
|
moderationButton='button'
|
||||||
|
@ -2065,6 +2076,8 @@ def htmlTimeline(translate: {},pageNumber: int, \
|
||||||
dmButton='buttonselectedhighlighted'
|
dmButton='buttonselectedhighlighted'
|
||||||
elif boxName=='tlreplies':
|
elif boxName=='tlreplies':
|
||||||
repliesButton='buttonselected'
|
repliesButton='buttonselected'
|
||||||
|
if newReply:
|
||||||
|
repliesButton='buttonselectedhighlighted'
|
||||||
elif boxName=='tlmedia':
|
elif boxName=='tlmedia':
|
||||||
mediaButton='buttonselected'
|
mediaButton='buttonselected'
|
||||||
elif boxName=='outbox':
|
elif boxName=='outbox':
|
||||||
|
|
Loading…
Reference in New Issue