diff --git a/inbox.py b/inbox.py index 3d9ae6e5..b11c62cc 100644 --- a/inbox.py +++ b/inbox.py @@ -10,6 +10,7 @@ import json import os import datetime import time +from utils import isEventPost from utils import removeIdEnding from utils import getProtocolPrefixes from utils import isBlogPost @@ -774,43 +775,6 @@ def receiveUndo(session, baseDir: str, httpPrefix: str, return False -def isEventPost(messageJson: {}) -> bool: - """Is the given post a mobilizon-type event activity? - See https://framagit.org/framasoft/mobilizon/-/blob/ - master/lib/federation/activity_stream/converter/event.ex - """ - if not messageJson.get('id'): - return False - if not messageJson.get('actor'): - return False - if not messageJson.get('object'): - return False - if not isinstance(messageJson['object'], dict): - return False - if not messageJson['object'].get('type'): - return False - if messageJson['object']['type'] != 'Event': - return False - print('Event arriving') - if not messageJson['object'].get('startTime'): - print('No event start time') - return False - if not messageJson['object'].get('actor'): - print('No event actor') - return False - if not messageJson['object'].get('content'): - print('No event content') - return False - if not messageJson['object'].get('name'): - print('No event name') - return False - if not messageJson['object'].get('uuid'): - print('No event UUID') - return False - print('Event detected') - return True - - def receiveEventPost(recentPostsCache: {}, session, baseDir: str, httpPrefix: str, domain: str, port: int, sendThreads: [], postLog: [], cachedWebfingers: {}, diff --git a/translations/ar.json b/translations/ar.json index 2e5b5b3e..14f9ced6 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -280,5 +280,6 @@ "Maximum attendees": "الحد الأقصى للحضور", "Ticket URL": "عنوان URL للتذكرة", "Create a new event": "أنشئ حدثًا جديدًا", - "Moderation policy or code of conduct": "سياسة الوسطية أو قواعد السلوك" + "Moderation policy or code of conduct": "سياسة الوسطية أو قواعد السلوك", + "Edit event": "تحرير الحدث" } diff --git a/translations/ca.json b/translations/ca.json index 81936700..e55e2c0e 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -280,5 +280,6 @@ "Maximum attendees": "Màxim d’assistents", "Ticket URL": "URL de l'entrada", "Create a new event": "Creeu un esdeveniment nou", - "Moderation policy or code of conduct": "Política de moderació o codi de conducta" + "Moderation policy or code of conduct": "Política de moderació o codi de conducta", + "Edit event": "Edita l’esdeveniment" } diff --git a/translations/cy.json b/translations/cy.json index f02707e1..7b93d64b 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -280,5 +280,6 @@ "Maximum attendees": "Uchafswm mynychwyr", "Ticket URL": "URL y tocyn", "Create a new event": "Creu digwyddiad newydd", - "Moderation policy or code of conduct": "Polisi cymedroli neu god ymddygiad" + "Moderation policy or code of conduct": "Polisi cymedroli neu god ymddygiad", + "Edit event": "Golygu digwyddiad" } diff --git a/translations/de.json b/translations/de.json index 3c28b13b..930c17b6 100644 --- a/translations/de.json +++ b/translations/de.json @@ -280,5 +280,6 @@ "Maximum attendees": "Maximale Teilnehmerzahl", "Ticket URL": "Ticket URL", "Create a new event": "Erstellen Sie ein neues Ereignis", - "Moderation policy or code of conduct": "Moderationsrichtlinie oder Verhaltenskodex" + "Moderation policy or code of conduct": "Moderationsrichtlinie oder Verhaltenskodex", + "Edit event": "Ereignis bearbeiten" } diff --git a/translations/en.json b/translations/en.json index 243a9c84..8c0e8b6d 100644 --- a/translations/en.json +++ b/translations/en.json @@ -280,5 +280,6 @@ "Maximum attendees": "Maximum attendees", "Ticket URL": "Ticket URL", "Create a new event": "Create a new event", - "Moderation policy or code of conduct": "Moderation policy or code of conduct" + "Moderation policy or code of conduct": "Moderation policy or code of conduct", + "Edit event": "Edit event" } diff --git a/translations/es.json b/translations/es.json index c1049c4e..5edcc885 100644 --- a/translations/es.json +++ b/translations/es.json @@ -280,5 +280,6 @@ "Maximum attendees": "Asistentes máximos", "Ticket URL": "URL del ticket", "Create a new event": "Crea un nuevo evento", - "Moderation policy or code of conduct": "Política de moderación o código de conducta" + "Moderation policy or code of conduct": "Política de moderación o código de conducta", + "Edit event": "Editar evento" } diff --git a/translations/fr.json b/translations/fr.json index d162a533..ca67d419 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -280,5 +280,6 @@ "Maximum attendees": "Nombre maximum de participants", "Ticket URL": "URL du ticket", "Create a new event": "Créer un nouvel événement", - "Moderation policy or code of conduct": "Politique de modération ou code de conduite" + "Moderation policy or code of conduct": "Politique de modération ou code de conduite", + "Edit event": "Modifier l'événement" } diff --git a/translations/ga.json b/translations/ga.json index 02b510ae..a746ae4d 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -280,5 +280,6 @@ "Maximum attendees": "Uasmhéid freastail", "Ticket URL": "URL na dticéad", "Create a new event": "Cruthaigh imeacht nua", - "Moderation policy or code of conduct": "Beartas modhnóireachta nó cód iompair" + "Moderation policy or code of conduct": "Beartas modhnóireachta nó cód iompair", + "Edit event": "Cuir imeacht in eagar" } diff --git a/translations/hi.json b/translations/hi.json index 21e9ef0e..ac11254a 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -280,5 +280,6 @@ "Maximum attendees": "अधिकतम उपस्थित", "Ticket URL": "टिकट URL", "Create a new event": "एक नई घटना बनाएँ", - "Moderation policy or code of conduct": "मॉडरेशन पॉलिसी या आचार संहिता" + "Moderation policy or code of conduct": "मॉडरेशन पॉलिसी या आचार संहिता", + "Edit event": "घटना संपादित करें" } diff --git a/translations/it.json b/translations/it.json index 18a8f125..72e8efe3 100644 --- a/translations/it.json +++ b/translations/it.json @@ -280,5 +280,6 @@ "Maximum attendees": "Numero massimo di partecipanti", "Ticket URL": "URL del biglietto", "Create a new event": "Crea un nuovo evento", - "Moderation policy or code of conduct": "Politica di moderazione o codice di condotta" + "Moderation policy or code of conduct": "Politica di moderazione o codice di condotta", + "Edit event": "Modifica evento" } diff --git a/translations/ja.json b/translations/ja.json index 01a57ec6..13fa27be 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -280,5 +280,6 @@ "Maximum attendees": "最大参加者", "Ticket URL": "チケットURL", "Create a new event": "新しいイベントを作成する", - "Moderation policy or code of conduct": "モデレートポリシーまたは行動規範" + "Moderation policy or code of conduct": "モデレートポリシーまたは行動規範", + "Edit event": "イベントを編集" } diff --git a/translations/oc.json b/translations/oc.json index d8610fa9..3642f117 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -276,5 +276,6 @@ "Maximum attendees": "Maximum attendees", "Ticket URL": "Ticket URL", "Create a new event": "Create a new event", - "Moderation policy or code of conduct": "Moderation policy or code of conduct" + "Moderation policy or code of conduct": "Moderation policy or code of conduct", + "Edit event": "Edit event" } diff --git a/translations/pt.json b/translations/pt.json index 82de1c0c..08fd34d5 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -280,5 +280,6 @@ "Maximum attendees": "Máximo de participantes", "Ticket URL": "URL do bilhete", "Create a new event": "Crie um novo evento", - "Moderation policy or code of conduct": "Política de moderação ou código de conduta" + "Moderation policy or code of conduct": "Política de moderação ou código de conduta", + "Edit event": "Editar evento" } diff --git a/translations/ru.json b/translations/ru.json index 42aed9c0..74456e43 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -280,5 +280,6 @@ "Maximum attendees": "Максимальное количество участников", "Ticket URL": "URL билета", "Create a new event": "Создать новое мероприятие", - "Moderation policy or code of conduct": "Политика модерации или кодекс поведения" + "Moderation policy or code of conduct": "Политика модерации или кодекс поведения", + "Edit event": "Изменить мероприятие" } diff --git a/translations/zh.json b/translations/zh.json index 6665093c..52e93e6e 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -280,5 +280,6 @@ "Maximum attendees": "参加人数上限", "Ticket URL": "工单URL", "Create a new event": "建立新活动", - "Moderation policy or code of conduct": "审核政策或行为准则" + "Moderation policy or code of conduct": "审核政策或行为准则", + "Edit event": "编辑活动" } diff --git a/utils.py b/utils.py index c4dc8f28..073e820a 100644 --- a/utils.py +++ b/utils.py @@ -807,6 +807,43 @@ def mergeDicts(dict1: {}, dict2: {}) -> {}: return res +def isEventPost(messageJson: {}) -> bool: + """Is the given post a mobilizon-type event activity? + See https://framagit.org/framasoft/mobilizon/-/blob/ + master/lib/federation/activity_stream/converter/event.ex + """ + if not messageJson.get('id'): + return False + if not messageJson.get('actor'): + return False + if not messageJson.get('object'): + return False + if not isinstance(messageJson['object'], dict): + return False + if not messageJson['object'].get('type'): + return False + if messageJson['object']['type'] != 'Event': + return False + print('Event arriving') + if not messageJson['object'].get('startTime'): + print('No event start time') + return False + if not messageJson['object'].get('actor'): + print('No event actor') + return False + if not messageJson['object'].get('content'): + print('No event content') + return False + if not messageJson['object'].get('name'): + print('No event name') + return False + if not messageJson['object'].get('uuid'): + print('No event UUID') + return False + print('Event detected') + return True + + def isBlogPost(postJsonObject: {}) -> bool: """Is the given post a blog post? """ diff --git a/webinterface.py b/webinterface.py index f79e0a53..e71fd8ac 100644 --- a/webinterface.py +++ b/webinterface.py @@ -29,6 +29,7 @@ from utils import removeIdEnding from utils import getProtocolPrefixes from utils import getFileCaseInsensitive from utils import searchBoxPosts +from utils import isEventPost from utils import isBlogPost from utils import updateRecentPostsCache from utils import getNicknameFromActor @@ -4019,20 +4020,35 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, translate['Reply to this post'] + \ ' |" src="/' + iconsDir + '/reply.png"/>\n' + isEvent = isEventPost(postJsonObject) + editStr = '' if fullDomain + '/users/' + nickname in postJsonObject['actor']: if '/statuses/' in postJsonObject['object']['id']: if isBlogPost(postJsonObject): + blogPostId = postJsonObject['object']['id'] editStr += \ '' + \ '' + \
                     translate['Edit blog post'] + \
                     ' |\n' + elif isEvent: + eventPostId = postJsonObject['object']['id'] + editStr += \ + '' + \ + '' + \
+                    translate['Edit event'] + \
+                    ' |\n' announceStr = '' if not isModerationPost and showRepeatIcon: