More content warning validation

main
Bob Mottram 2020-08-25 20:45:15 +01:00
parent 8d6b8f98b0
commit a484936793
1 changed files with 10 additions and 0 deletions

View File

@ -50,6 +50,7 @@ from filters import isFiltered
from announce import updateAnnounceCollection from announce import updateAnnounceCollection
from announce import undoAnnounceCollectionEntry from announce import undoAnnounceCollectionEntry
from httpsig import messageContentDigest from httpsig import messageContentDigest
from posts import validContentWarning
from posts import downloadAnnounce from posts import downloadAnnounce
from posts import isDM from posts import isDM
from posts import isReply from posts import isReply
@ -1708,6 +1709,15 @@ def validPostContent(baseDir: str, nickname: str, domain: str,
if 'Z' not in messageJson['object']['published']: if 'Z' not in messageJson['object']['published']:
return False return False
if messageJson['object'].get('summary'):
summary = messageJson['object']['summary']
if not isinstance(summary, str):
print('WARN: content warning is not a string')
return False
if summary != validContentWarning(summary):
print('WARN: invalid content warning ' + summary)
return False
if isGitPatch(baseDir, nickname, domain, if isGitPatch(baseDir, nickname, domain,
messageJson['object']['type'], messageJson['object']['type'],
messageJson['object']['summary'], messageJson['object']['summary'],