From b466e333043707854c2138b35e04e42183db08d4 Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Mon, 29 Jun 2020 17:53:02 +0100
Subject: [PATCH] Set petname from person options
---
daemon.py | 18 ++++++++++++++++++
webinterface.py | 4 +++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/daemon.py b/daemon.py
index e5771be9..da7d5648 100644
--- a/daemon.py
+++ b/daemon.py
@@ -184,6 +184,7 @@ from outbox import postMessageToOutbox
from happening import removeCalendarEvent
from bookmarks import bookmark
from bookmarks import undoBookmark
+from petnames import setPetName
import os
@@ -7593,6 +7594,11 @@ class PubServer(BaseHTTPRequestHandler):
postUrl = optionsConfirmParams.split('postUrl=')[1]
if '&' in postUrl:
postUrl = postUrl.split('&')[0]
+ petname = None
+ if 'optionpetname' in optionsConfirmParams:
+ petname = optionsConfirmParams.split('optionpetname=')[1]
+ if '&' in petname:
+ petname = petname.split('&')[0]
optionsNickname = getNicknameFromActor(optionsActor)
if not optionsNickname:
@@ -7628,6 +7634,18 @@ class PubServer(BaseHTTPRequestHandler):
cookie, callingDomain)
self.server.POSTbusy = False
return
+ if '&submitPetname=' in optionsConfirmParams and petname:
+ if self.server.debug:
+ print('Change petname to ' + petname)
+ handle = optionsNickname + '@' + optionsDomainFull
+ setPetName(self.server.baseDir,
+ chooserNickname,
+ self.server.domain,
+ handle, petname)
+ self._redirect_headers(optionsActor,
+ cookie, callingDomain)
+ self.server.POSTbusy = False
+ return
if '&submitBlock=' in optionsConfirmParams:
if self.server.debug:
print('Adding block by ' + chooserNickname +
diff --git a/webinterface.py b/webinterface.py
index b6cf6b61..a977d0c2 100644
--- a/webinterface.py
+++ b/webinterface.py
@@ -5420,7 +5420,9 @@ def htmlPersonOptions(translate: {}, baseDir: str,
optionsStr += \
'' + translate['Petname'] + ': ' + \
'
'
+ petname + '">' \
+ '
'
optionsStr += optionsLinkStr
optionsStr += \
'