Revert "Remove wait screen"

This reverts commit 1c0770120c.
main
Bob Mottram 2020-09-28 17:25:22 +01:00
parent 1c0770120c
commit bb391c8f98
17 changed files with 271 additions and 15 deletions

205
daemon.py
View File

@ -152,6 +152,7 @@ from webinterface import rssHashtagSearch
from webinterface import htmlModerationInfo
from webinterface import htmlSearchSharedItems
from webinterface import htmlHashtagBlocked
from webinterface import htmlSendingPost
from shares import getSharesFeedForPerson
from shares import addShare
from shares import removeShare
@ -9132,6 +9133,62 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers_head(mediaFileType, fileLength,
etag, callingDomain)
def _showSendingScreen(self, authorized: bool, callingDomain: str) -> None:
"""Shows a 'sending post' wait screen
"""
if self.server.defaultTimeline != 'inbox':
return
if not self._requestHTTP():
return
# make a copy of the headers
currHeaders = self.headers.items()
# show a sending post screen
msg = \
htmlSendingPost(self.server.baseDir,
self.server.translate).encode('utf-8')
self._login_headers('text/html', len(msg), callingDomain)
self._write(msg)
self.wfile.flush()
# restore headers
for headerField in currHeaders:
fieldName = headerField[0]
fieldValue = headerField[1]
self.headers[fieldName] = fieldValue
def _clearSendingScreen(self, authorized: bool,
boxName: str, path: str,
callingDomain: str, cookie: str) -> None:
"""Redirects to the given box
"""
if boxName != 'inbox':
return
if not self._requestHTTP():
return
self._showInbox(authorized,
callingDomain, self.path,
self.server.baseDir,
self.server.httpPrefix,
self.server.domain,
self.server.domainFull,
self.server.port,
self.server.onionDomain,
self.server.i2pDomain,
None, None,
self.server.proxyType,
cookie, self.server.debug,
self.server.recentPostsCache,
self.server.session,
self.server.defaultTimeline,
self.server.maxRecentPosts,
self.server.translate,
self.server.cachedWebfingers,
self.server.personCache,
self.server.allowDeletion,
self.server.projectVersion,
self.server.YTReplacementDomain)
def _receiveNewPostProcess(self, postType: str, path: str, headers: {},
length: int, postBytes, boundary: str,
callingDomain: str, cookie: str,
@ -9277,6 +9334,12 @@ class PubServer(BaseHTTPRequestHandler):
else:
privateEvent = True
# self._showSendingScreen(authorized, callingDomain)
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
if postType == 'newpost':
messageJson = \
createPublicPost(self.server.baseDir,
@ -9295,6 +9358,10 @@ class PubServer(BaseHTTPRequestHandler):
fields['location'])
if messageJson:
if fields['schedulePost']:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
if self._postToOutbox(messageJson, __version__, nickname):
@ -9304,8 +9371,16 @@ class PubServer(BaseHTTPRequestHandler):
messageJson,
self.server.maxReplies,
self.server.debug)
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'newblog':
messageJson = \
@ -9323,6 +9398,10 @@ class PubServer(BaseHTTPRequestHandler):
fields['location'])
if messageJson:
if fields['schedulePost']:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
if self._postToOutbox(messageJson, __version__, nickname):
populateReplies(self.server.baseDir,
@ -9331,8 +9410,16 @@ class PubServer(BaseHTTPRequestHandler):
messageJson,
self.server.maxReplies,
self.server.debug)
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'editblogpost':
print('Edited blog post received')
@ -9401,6 +9488,10 @@ class PubServer(BaseHTTPRequestHandler):
self.server.YTReplacementDomain)
saveJson(postJsonObject, postFilename)
print('Edited blog post, resaved ' + postFilename)
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
print('Edited blog post, unable to load json for ' +
@ -9408,6 +9499,9 @@ class PubServer(BaseHTTPRequestHandler):
else:
print('Edited blog post not found ' +
str(fields['postUrl']))
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
elif postType == 'newunlisted':
messageJson = \
@ -9429,6 +9523,10 @@ class PubServer(BaseHTTPRequestHandler):
fields['location'])
if messageJson:
if fields['schedulePost']:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
if self._postToOutbox(messageJson, __version__, nickname):
populateReplies(self.server.baseDir,
@ -9437,8 +9535,16 @@ class PubServer(BaseHTTPRequestHandler):
messageJson,
self.server.maxReplies,
self.server.debug)
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'newfollowers':
messageJson = \
@ -9462,6 +9568,10 @@ class PubServer(BaseHTTPRequestHandler):
fields['location'])
if messageJson:
if fields['schedulePost']:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
if self._postToOutbox(messageJson, __version__, nickname):
populateReplies(self.server.baseDir,
@ -9470,8 +9580,16 @@ class PubServer(BaseHTTPRequestHandler):
messageJson,
self.server.maxReplies,
self.server.debug)
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'newevent':
# A Mobilizon-type event is posted
@ -9522,10 +9640,22 @@ class PubServer(BaseHTTPRequestHandler):
fields['ticketUrl'])
if messageJson:
if fields['schedulePost']:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
if self._postToOutbox(messageJson, __version__, nickname):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'newdm':
messageJson = None
@ -9553,6 +9683,10 @@ class PubServer(BaseHTTPRequestHandler):
fields['location'])
if messageJson:
if fields['schedulePost']:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
print('Sending new DM to ' +
str(messageJson['object']['to']))
@ -9563,8 +9697,16 @@ class PubServer(BaseHTTPRequestHandler):
messageJson,
self.server.maxReplies,
self.server.debug)
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'newreminder':
messageJson = None
@ -9591,16 +9733,32 @@ class PubServer(BaseHTTPRequestHandler):
fields['location'])
if messageJson:
if fields['schedulePost']:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
print('DEBUG: new reminder to ' +
str(messageJson['object']['to']))
if self._postToOutbox(messageJson, __version__, nickname):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'newreport':
if attachmentMediaType:
if attachmentMediaType != 'image':
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
# So as to be sure that this only goes to moderators
# and not accounts being reported we disable any
@ -9619,13 +9777,28 @@ class PubServer(BaseHTTPRequestHandler):
self.server.debug, fields['subject'])
if messageJson:
if self._postToOutbox(messageJson, __version__, nickname):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
else:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
elif postType == 'newquestion':
if not fields.get('duration'):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
if not fields.get('message'):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
# questionStr = fields['message']
qOptions = []
@ -9634,6 +9807,9 @@ class PubServer(BaseHTTPRequestHandler):
qOptions.append(fields['questionOption' +
str(questionCtr)])
if not qOptions:
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
messageJson = \
createQuestionPost(self.server.baseDir,
@ -9653,19 +9829,42 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.debug:
print('DEBUG: new Question')
if self._postToOutbox(messageJson, __version__, nickname):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return 1
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
elif postType == 'newshare':
if not fields.get('itemType'):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
if not fields.get('category'):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
if not fields.get('location'):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
if not fields.get('duration'):
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
if attachmentMediaType:
if attachmentMediaType != 'image':
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain,
cookie)
return -1
durationStr = fields['duration']
if durationStr:
@ -9687,7 +9886,13 @@ class PubServer(BaseHTTPRequestHandler):
if os.path.isfile(filename):
os.remove(filename)
self.postToNickname = nickname
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return 1
self._clearSendingScreen(authorized,
self.server.defaultTimeline,
self.path, callingDomain, cookie)
return -1
def _receiveNewPost(self, postType: str, path: str,

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "علامات التجزئة المُنشأة تلقائيًا",
"Autogenerated Content Warnings": "تحذيرات المحتوى المُنشأ تلقائيًا",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag محظور"
"Hashtag Blocked": "Hashtag محظور",
"Sending Post": "إرسال آخر",
"Please wait": "ارجوك انتظر"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Hashtags autogenerats",
"Autogenerated Content Warnings": "Advertiments de contingut autogenerats",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag bloquejat"
"Hashtag Blocked": "Hashtag bloquejat",
"Sending Post": "S'està enviant el missatge",
"Please wait": "Espereu, si us plau"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Hashtags awtogeneiddiedig",
"Autogenerated Content Warnings": "Rhybuddion Cynnwys Autogenerated",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag wedi'i Blocio"
"Hashtag Blocked": "Hashtag wedi'i Blocio",
"Sending Post": "Post Anfon",
"Please wait": "Arhoswch os gwelwch yn dda"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Automatisch generierte Hashtags",
"Autogenerated Content Warnings": "Warnungen vor automatisch generierten Inhalten",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag blockiert"
"Hashtag Blocked": "Hashtag blockiert",
"Sending Post": "Post senden",
"Please wait": "Warten Sie mal"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Autogenerated Hashtags",
"Autogenerated Content Warnings": "Autogenerated Content Warnings",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag Blocked"
"Hashtag Blocked": "Hashtag Blocked",
"Sending Post": "Sending Post",
"Please wait": "Please wait"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Hashtags autogenerados",
"Autogenerated Content Warnings": "Advertencias de contenido generado automáticamente",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag bloqueada"
"Hashtag Blocked": "Hashtag bloqueada",
"Sending Post": "Envío de publicación",
"Please wait": "por favor espera"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Hashtags générés automatiquement",
"Autogenerated Content Warnings": "Avertissements de contenu générés automatiquement",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag bloqué"
"Hashtag Blocked": "Hashtag bloqué",
"Sending Post": "Envoi du message",
"Please wait": "S'il vous plaît, attendez"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Hashtags uathghinte",
"Autogenerated Content Warnings": "Rabhaidh Ábhar Uathghinte",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag Blocáilte"
"Hashtag Blocked": "Hashtag Blocáilte",
"Sending Post": "Post Seolta",
"Please wait": "Fán le do thoil"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "ऑटोजेनरेटेड हैशटैग",
"Autogenerated Content Warnings": "स्वतः प्राप्त सामग्री चेतावनी",
"Indymedia": "Indymedia",
"Hashtag Blocked": "हैशटैग अवरुद्ध"
"Hashtag Blocked": "हैशटैग अवरुद्ध",
"Sending Post": "पोस्ट भेज रहा है",
"Please wait": "कृपया प्रतीक्षा कीजिये"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Hashtag generati automaticamente",
"Autogenerated Content Warnings": "Avvisi sui contenuti generati automaticamente",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag bloccato"
"Hashtag Blocked": "Hashtag bloccato",
"Sending Post": "Invio di post",
"Please wait": "attendere prego"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "自動生成されたハッシュタグ",
"Autogenerated Content Warnings": "自動生成されたコンテンツの警告",
"Indymedia": "Indymedia",
"Hashtag Blocked": "ハッシュタグがブロックされました"
"Hashtag Blocked": "ハッシュタグがブロックされました",
"Sending Post": "投稿を送信する",
"Please wait": "お待ちください"
}

View File

@ -283,5 +283,7 @@
"Autogenerated Hashtags": "Autogenerated Hashtags",
"Autogenerated Content Warnings": "Autogenerated Content Warnings",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag Blocked"
"Hashtag Blocked": "Hashtag Blocked",
"Sending Post": "Sending Post",
"Please wait": "Please wait"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Hashtags autogeradas",
"Autogenerated Content Warnings": "Avisos de conteúdo gerado automaticamente",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Hashtag bloqueada"
"Hashtag Blocked": "Hashtag bloqueada",
"Sending Post": "Enviando postagem",
"Please wait": "Por favor, espere"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "Автоматически сгенерированные хештеги",
"Autogenerated Content Warnings": "Автоматические предупреждения о содержании",
"Indymedia": "Indymedia",
"Hashtag Blocked": "Хештег заблокирован"
"Hashtag Blocked": "Хештег заблокирован",
"Sending Post": "Отправка сообщения",
"Please wait": "пожалуйста, подождите"
}

View File

@ -287,5 +287,7 @@
"Autogenerated Hashtags": "自动生成的标签",
"Autogenerated Content Warnings": "自动生成的内容警告",
"Indymedia": "Indymedia",
"Hashtag Blocked": "标签被阻止"
"Hashtag Blocked": "标签被阻止",
"Sending Post": "发送帖子",
"Please wait": "请稍候"
}

View File

@ -2006,6 +2006,27 @@ def htmlHashtagBlocked(baseDir: str, translate: {}) -> str:
return blockedHashtagForm
def htmlSendingPost(baseDir: str, translate: {}) -> str:
"""A wait screen while sending a post
"""
sendForm = ''
cssFilename = baseDir + '/epicyon-send.css'
if os.path.isfile(baseDir + '/send.css'):
cssFilename = baseDir + '/send.css'
with open(cssFilename, 'r') as cssFile:
sendingCSS = cssFile.read()
sendForm = htmlHeader(cssFilename, sendingCSS)
sendForm += '<div><center>\n'
sendForm += \
' <p class="screentitle">' + \
translate['Sending Post'] + '</p>\n'
sendForm += \
' <p>' + translate['Please wait'] + '</p>\n'
sendForm += '</center></div>\n'
sendForm += htmlFooter()
return sendForm
def htmlSuspended(baseDir: str) -> str:
"""Show the screen for suspended accounts
"""