mirror of https://gitlab.com/bashrc2/epicyon
Check if tag already exists
parent
9d176ab77d
commit
88b0a6aa6f
|
@ -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
|
||||
|
|
4
posts.py
4
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))
|
||||
|
|
2
tests.py
2
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'] == \
|
||||
'<p><span class=\"h-card\">' + \
|
||||
'<a href=\"https://rat.site/@ninjarodent\" ' + \
|
||||
|
|
Loading…
Reference in New Issue