Include post id in reject messages

main2
Bob Mottram 2019-09-30 11:37:34 +01:00
parent 0f2c863e4e
commit b75faf7ac8
1 changed files with 4 additions and 0 deletions

View File

@ -1128,12 +1128,16 @@ def validPostContent(messageJson: {},maxMentions: int) -> bool:
return False return False
# check (rough) number of mentions # check (rough) number of mentions
if estimateNumberOfMentions(messageJson['object']['content'])>maxMentions: if estimateNumberOfMentions(messageJson['object']['content'])>maxMentions:
if messageJson['object'].get('id'):
print('REJECT: '+messageJson['object']['id'])
print('REJECT: Too many mentions in post - '+messageJson['object']['content']) print('REJECT: Too many mentions in post - '+messageJson['object']['content'])
return False return False
# check number of tags # check number of tags
if messageJson['object'].get('tag'): if messageJson['object'].get('tag'):
if isinstance(messageJson['object']['tag'], list): if isinstance(messageJson['object']['tag'], list):
if len(messageJson['object']['tag'])>maxMentions*2: if len(messageJson['object']['tag'])>maxMentions*2:
if messageJson['object'].get('id'):
print('REJECT: '+messageJson['object']['id'])
print('REJECT: Too many tags in post - '+messageJson['object']['tag']) print('REJECT: Too many tags in post - '+messageJson['object']['tag'])
return False return False
print('ACCEPT: post content is valid') print('ACCEPT: post content is valid')