kopia lustrzana https://github.com/Langenfeld/py-gitea
Now possible to get actual Mail of User.
rodzic
3e955f0761
commit
e2eb56d84c
|
@ -155,6 +155,7 @@ class User:
|
||||||
login: string
|
login: string
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
USER_MAIL = """/user/emails?sudo=%s""" # <name>
|
||||||
USER_REQUEST = """/users/%s""" # <org>
|
USER_REQUEST = """/users/%s""" # <org>
|
||||||
USER_REPOS_REQUEST = """/users/%s/repos""" # <org>
|
USER_REPOS_REQUEST = """/users/%s/repos""" # <org>
|
||||||
USER_PATCH = """/admin/users/%s""" # <username>
|
USER_PATCH = """/admin/users/%s""" # <username>
|
||||||
|
@ -207,6 +208,18 @@ class User:
|
||||||
for i, v in result.items():
|
for i, v in result.items():
|
||||||
setattr(self, i, v)
|
setattr(self, i, v)
|
||||||
|
|
||||||
|
def update_mail(self):
|
||||||
|
""" Update the mail of this user instance to one that is \
|
||||||
|
actually correct.
|
||||||
|
"""
|
||||||
|
prev = self.email
|
||||||
|
result = self.gitea.requests_get(User.USER_MAIL % self.login)
|
||||||
|
for mail in result:
|
||||||
|
if mail['primary']:
|
||||||
|
self.email = mail['email']
|
||||||
|
break
|
||||||
|
logging.info("User %s updated Mail: <%s> to <%s>" % (self.login, prev, self.email))
|
||||||
|
|
||||||
def set_value(self, email: str, values: dict):
|
def set_value(self, email: str, values: dict):
|
||||||
""" Set certain values of this user.
|
""" Set certain values of this user.
|
||||||
|
|
||||||
|
@ -568,7 +581,7 @@ class Gitea():
|
||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
data=json.dumps(data))
|
data=json.dumps(data))
|
||||||
if request.status_code not in [200, 201]:
|
if request.status_code not in [200, 201]:
|
||||||
if 'already exists' in request.text:
|
if 'already exists' in request.text or 'e-mail already in use' in request.text:
|
||||||
logging.warning(request.text)
|
logging.warning(request.text)
|
||||||
raise AlreadyExistsException()
|
raise AlreadyExistsException()
|
||||||
logging.error("Received status code: %s (%s)" %
|
logging.error("Received status code: %s (%s)" %
|
||||||
|
|
Ładowanie…
Reference in New Issue