wiki upgrade
This commit is contained in:
22
wiki/api.py
22
wiki/api.py
@@ -3,9 +3,11 @@ import urllib.parse
|
||||
from etherpad_lite import EtherpadLiteClient, EtherpadException
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
#SERVER_URL = settings.ETHERPAD_CLIENT["exturl"]
|
||||
logger.info("loading api.py")
|
||||
|
||||
class EtherpadLiteLazyAPI():
|
||||
"""This is a small wrapper for EtherpadLiteClient
|
||||
url is the url with port the client should connect to.
|
||||
@@ -99,3 +101,23 @@ class EtherpadLiteLazyAPI():
|
||||
if padID is None: return "#"
|
||||
if not self.connect(): return "#"
|
||||
return urllib.parse.urljoin(self.exturl, 'p/' + self.group["groupID"] + '$' + str(padID))
|
||||
|
||||
def getSessionID(self, username):
|
||||
if not self.connect(): return "#"
|
||||
author = self.epc.createAuthorIfNotExistsFor(
|
||||
name=str(username),
|
||||
authorMapper=str(username)
|
||||
)['authorID']
|
||||
|
||||
expires = datetime.utcnow() + timedelta(hours=3)
|
||||
try:
|
||||
result = self.epc.createSession(
|
||||
groupID=str(self.group['groupID']),
|
||||
authorID=str(author),
|
||||
validUntil=str(int(expires.timestamp()))
|
||||
)
|
||||
except Exception as e:
|
||||
raise e
|
||||
return None
|
||||
return result['sessionID']#, expires
|
||||
|
||||
|
||||
Reference in New Issue
Block a user