mirror of https://gitlab.com/bashrc2/epicyon
Set reply interval from edit profile screen
parent
9601220e66
commit
4ae19caeb4
11
daemon.py
11
daemon.py
|
@ -232,6 +232,7 @@ from categories import updateHashtagCategories
|
|||
from languages import getActorLanguages
|
||||
from languages import setActorLanguages
|
||||
from like import updateLikesCollection
|
||||
from utils import setReplyIntervalHours
|
||||
from utils import canReplyTo
|
||||
from utils import isDM
|
||||
from utils import replaceUsersWithAt
|
||||
|
@ -4539,6 +4540,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
storeBasicCredentials(baseDir, nickname,
|
||||
fields['password'])
|
||||
|
||||
# reply interval in hours
|
||||
if fields.get('replyhours'):
|
||||
if fields['replyhours'].isdigit():
|
||||
setReplyIntervalHours(baseDir, nickname, domain,
|
||||
fields['replyhours'])
|
||||
|
||||
# change city
|
||||
if fields.get('cityDropdown'):
|
||||
cityFilename = \
|
||||
|
@ -11367,6 +11374,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self.server.keyShortcuts.get(nickname):
|
||||
accessKeys = self.server.keyShortcuts[nickname]
|
||||
|
||||
defaultReplyIntervalHours = self.server.defaultReplyIntervalHours
|
||||
msg = htmlEditProfile(self.server.cssCache,
|
||||
translate,
|
||||
baseDir,
|
||||
|
@ -11379,7 +11387,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.textModeBanner,
|
||||
city,
|
||||
self.server.userAgentsBlocked,
|
||||
accessKeys).encode('utf-8')
|
||||
accessKeys,
|
||||
defaultReplyIntervalHours).encode('utf-8')
|
||||
if msg:
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "انخفاض النطاق الترددي",
|
||||
"accommodation": "الإقامة",
|
||||
"Forbidden": "محرم",
|
||||
"You're not allowed": "كنت لا يسمح"
|
||||
"You're not allowed": "كنت لا يسمح",
|
||||
"Hours after posting during which replies are allowed": "ساعات بعد النشر المسموح بها خلال الردود"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Ample de banda baixa",
|
||||
"accommodation": "allotjament",
|
||||
"Forbidden": "Prohibit",
|
||||
"You're not allowed": "No està permès"
|
||||
"You're not allowed": "No està permès",
|
||||
"Hours after posting during which replies are allowed": "Hores després de la publicació durant les respostes"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Lled band isel",
|
||||
"accommodation": "llety",
|
||||
"Forbidden": "Wedi'i wahardd",
|
||||
"You're not allowed": "Ni chaniateir i chi"
|
||||
"You're not allowed": "Ni chaniateir i chi",
|
||||
"Hours after posting during which replies are allowed": "Oriau ar ôl postio pan ganiateir atebion"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Niedrige Bandbreite",
|
||||
"accommodation": "unterkunft",
|
||||
"Forbidden": "Verboten",
|
||||
"You're not allowed": "Du darfst nicht"
|
||||
"You're not allowed": "Du darfst nicht",
|
||||
"Hours after posting during which replies are allowed": "Stunden nach dem Posten, während denen Antworten erlaubt sind"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Low Bandwidth",
|
||||
"accommodation": "accommodation",
|
||||
"Forbidden": "Forbidden",
|
||||
"You're not allowed": "You're not allowed"
|
||||
"You're not allowed": "You're not allowed",
|
||||
"Hours after posting during which replies are allowed": "Hours after posting during which replies are allowed"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Ancho de banda bajo",
|
||||
"accommodation": "alojamiento",
|
||||
"Forbidden": "Prohibida",
|
||||
"You're not allowed": "No tienes permiso"
|
||||
"You're not allowed": "No tienes permiso",
|
||||
"Hours after posting during which replies are allowed": "Horas después de la publicación durante las cuales se permiten las respuestas"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Bas débit",
|
||||
"accommodation": "hébergement",
|
||||
"Forbidden": "Interdite",
|
||||
"You're not allowed": "Tu n'as pas le droit"
|
||||
"You're not allowed": "Tu n'as pas le droit",
|
||||
"Hours after posting during which replies are allowed": "Heures après la publication pendant laquelle les réponses sont autorisées"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Bandaleithead íseal",
|
||||
"accommodation": "lóistín",
|
||||
"Forbidden": "Toirmiscthe",
|
||||
"You're not allowed": "Níl cead agat"
|
||||
"You're not allowed": "Níl cead agat",
|
||||
"Hours after posting during which replies are allowed": "Uair an chloig tar éis an phostála ina gceadaítear freagraí"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "कम बैंडविड्थ",
|
||||
"accommodation": "निवास स्थान",
|
||||
"Forbidden": "निषिद्ध",
|
||||
"You're not allowed": "आपको अनुमति नहीं है"
|
||||
"You're not allowed": "आपको अनुमति नहीं है",
|
||||
"Hours after posting during which replies are allowed": "पोस्ट करने के कुछ घंटे जिसके बाद जवाब देने की अनुमति है"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Bassa larghezza di banda",
|
||||
"accommodation": "struttura ricettiva",
|
||||
"Forbidden": "Proibita",
|
||||
"You're not allowed": "Non ti è permesso"
|
||||
"You're not allowed": "Non ti è permesso",
|
||||
"Hours after posting during which replies are allowed": "Ore dopo la pubblicazione durante le quali le risposte sono consentite"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "低帯域幅",
|
||||
"accommodation": "宿泊施設",
|
||||
"Forbidden": "禁断",
|
||||
"You're not allowed": "あなたは許可されていません"
|
||||
"You're not allowed": "あなたは許可されていません",
|
||||
"Hours after posting during which replies are allowed": "転記後の時間返信が許可されています"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Bandwidth kêm",
|
||||
"accommodation": "cih",
|
||||
"Forbidden": "Qedexekirî",
|
||||
"You're not allowed": "Destûrê nadin te"
|
||||
"You're not allowed": "Destûrê nadin te",
|
||||
"Hours after posting during which replies are allowed": "Demjimêran piştî şandina di dema bersivê de destûr tê dayîn"
|
||||
}
|
||||
|
|
|
@ -473,5 +473,6 @@
|
|||
"Low Bandwidth": "Low Bandwidth",
|
||||
"accommodation": "accommodation",
|
||||
"Forbidden": "Forbidden",
|
||||
"You're not allowed": "You're not allowed"
|
||||
"You're not allowed": "You're not allowed",
|
||||
"Hours after posting during which replies are allowed": "Hours after posting during which replies are allowed"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Baixa largura de banda",
|
||||
"accommodation": "alojamento",
|
||||
"Forbidden": "Proibida",
|
||||
"You're not allowed": "Você não tem permissão"
|
||||
"You're not allowed": "Você não tem permissão",
|
||||
"Hours after posting during which replies are allowed": "Horas após a postagem durante as quais as respostas são permitidas"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Низкая пропускная способность",
|
||||
"accommodation": "размещение",
|
||||
"Forbidden": "Запрещенный",
|
||||
"You're not allowed": "Вам не разрешено"
|
||||
"You're not allowed": "Вам не разрешено",
|
||||
"Hours after posting during which replies are allowed": "Часы после размещения, в течение которых разрешены ответы"
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "Bandwidth ya chini",
|
||||
"accommodation": "malazi",
|
||||
"Forbidden": "Imekatazwa",
|
||||
"You're not allowed": "Hauruhusiwi"
|
||||
"You're not allowed": "Hauruhusiwi",
|
||||
"Hours after posting during which replies are allowed": "Masaa baada ya kuchapisha wakati majibu yanaruhusiwa."
|
||||
}
|
||||
|
|
|
@ -477,5 +477,6 @@
|
|||
"Low Bandwidth": "低带宽",
|
||||
"accommodation": "住所",
|
||||
"Forbidden": "禁止的",
|
||||
"You're not allowed": "你不被允许"
|
||||
"You're not allowed": "你不被允许",
|
||||
"Hours after posting during which replies are allowed": "发布后的时间允许答复"
|
||||
}
|
||||
|
|
19
utils.py
19
utils.py
|
@ -1350,6 +1350,23 @@ def getReplyIntervalHours(baseDir: str, nickname: str, domain: str,
|
|||
return defaultReplyIntervalHours
|
||||
|
||||
|
||||
def setReplyIntervalHours(baseDir: str, nickname: str, domain: str,
|
||||
replyIntervalHours: int) -> bool:
|
||||
"""Sets the reply interval for the given account.
|
||||
The reply interval is the number of hours after a post being made
|
||||
during which replies are allowed
|
||||
"""
|
||||
replyIntervalFilename = \
|
||||
acctDir(baseDir, nickname, domain) + '/.replyIntervalHours'
|
||||
with open(replyIntervalFilename, 'w+') as fp:
|
||||
try:
|
||||
fp.write(str(replyIntervalHours))
|
||||
return True
|
||||
except BaseException:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def canReplyTo(baseDir: str, nickname: str, domain: str,
|
||||
postUrl: str, replyIntervalHours: int,
|
||||
currDateStr: str = None) -> bool:
|
||||
|
@ -1380,7 +1397,7 @@ def canReplyTo(baseDir: str, nickname: str, domain: str,
|
|||
return False
|
||||
hoursSincePublication = int((currDate - pubDate).total_seconds() / 3600)
|
||||
if hoursSincePublication < 0 or \
|
||||
hoursSincePublication > replyIntervalHours:
|
||||
hoursSincePublication >= replyIntervalHours:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ from utils import getImageFormats
|
|||
from utils import acctDir
|
||||
from utils import getSupportedLanguages
|
||||
from utils import localActorUrl
|
||||
from utils import getReplyIntervalHours
|
||||
from languages import getActorLanguages
|
||||
from skills import getSkills
|
||||
from theme import getThemesList
|
||||
|
@ -1435,7 +1436,8 @@ def _htmlEditProfileSharedItems(baseDir: str, nickname: str, domain: str,
|
|||
|
||||
|
||||
def _htmlEditProfileFiltering(baseDir: str, nickname: str, domain: str,
|
||||
userAgentsBlocked: str, translate: {}) -> str:
|
||||
userAgentsBlocked: str, translate: {},
|
||||
replyIntervalHours: int) -> str:
|
||||
"""Filtering and blocking section of edit profile screen
|
||||
"""
|
||||
filterStr = ''
|
||||
|
@ -1489,6 +1491,14 @@ def _htmlEditProfileFiltering(baseDir: str, nickname: str, domain: str,
|
|||
|
||||
editProfileForm = beginEditSection(translate['Filtering and Blocking'])
|
||||
|
||||
idx = 'Hours after posting during which replies are allowed'
|
||||
editProfileForm += \
|
||||
' <label class="labels">' + \
|
||||
translate[idx] + \
|
||||
':</label> <input type="number" name="replyhours" ' + \
|
||||
'min="0" max="999999999999" step="1" ' + \
|
||||
'value="' + str(replyIntervalHours) + '"><br>\n'
|
||||
|
||||
editProfileForm += \
|
||||
'<label class="labels">' + \
|
||||
translate['City for spoofed GPS image metadata'] + \
|
||||
|
@ -1864,7 +1874,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
peertubeInstances: [],
|
||||
textModeBanner: str, city: str,
|
||||
userAgentsBlocked: str,
|
||||
accessKeys: {}) -> str:
|
||||
accessKeys: {},
|
||||
defaultReplyIntervalHours: int) -> str:
|
||||
"""Shows the edit profile screen
|
||||
"""
|
||||
path = path.replace('/inbox', '').replace('/outbox', '')
|
||||
|
@ -2048,9 +2059,12 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
editProfileForm += libretranslateStr
|
||||
|
||||
# Filtering and blocking section
|
||||
replyIntervalHours = getReplyIntervalHours(baseDir, nickname, domain,
|
||||
defaultReplyIntervalHours)
|
||||
editProfileForm += \
|
||||
_htmlEditProfileFiltering(baseDir, nickname, domain,
|
||||
userAgentsBlocked, translate)
|
||||
userAgentsBlocked, translate,
|
||||
replyIntervalHours)
|
||||
|
||||
# git projects section
|
||||
editProfileForm += \
|
||||
|
|
Loading…
Reference in New Issue