diff --git a/content.py b/content.py index 4de6effa4..be9afd3ae 100644 --- a/content.py +++ b/content.py @@ -508,6 +508,15 @@ def addEmoji(baseDir: str, wordStr: str, return True +def tagExists(tagType: str, tagName: str, tags: {}) -> bool: + """Returns true if a tag exists in the given dict + """ + for tag in tags: + if tag['name'] == tagName and tag['type'] == tagType: + return True + return False + + def addMention(wordStr: str, httpPrefix: str, following: str, replaceMentions: {}, recipients: [], tags: {}) -> bool: """Detects mentions and adds them to the replacements dict and diff --git a/posts.py b/posts.py index 01d8b9fd6..0d3715013 100644 --- a/posts.py +++ b/posts.py @@ -52,6 +52,7 @@ from utils import votesOnNewswireItem from utils import removeHtml from media import attachMedia from media import replaceYouTube +from content import tagExists from content import removeLongWords from content import addHtmlTags from content import replaceEmojiFromTags @@ -801,7 +802,8 @@ def createPostBase(baseDir: str, nickname: str, domain: str, port: int, isPublic = True break for tagName, tag in hashtagsDict.items(): - tags.append(tag) + if not tagExists(tag['type'], tag['name'], tags): + tags.append(tag) if isPublic: updateHashtagsIndex(baseDir, tag, newPostId) print('Content tags: ' + str(tags)) diff --git a/tests.py b/tests.py index 8329152d2..fc8d9d739 100644 --- a/tests.py +++ b/tests.py @@ -2506,7 +2506,7 @@ def testReplyToPublicPost() -> None: "@ninjarodent@rat.site This is a test.", False, False, False, True, None, None, False, postId) - print(str(reply)) + # print(str(reply)) assert reply['object']['content'] == \ '