[dd-admin] Fix issue propagating changes to NC

There was erroneous logic that only propagated the first attribute of
many, so some attribute changes were never propagated to NextCloud.
develop
Evilham 2022-10-30 20:01:44 +01:00
parent 895a20abba
commit 071bcd827f
No known key found for this signature in database
GPG Key ID: AE3EE30D970886BF
1 changed files with 6 additions and 10 deletions

View File

@ -262,9 +262,9 @@ class Nextcloud:
def update_user(self, userid : str, key_values : Dict[str, Any]) -> bool:
# key_values={'quota':quota,'email':email,'displayname':displayname}
url = self.apiurl + "users/" + userid + "?format=json"
url = f"{self.apiurl}users/{userid}"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
"OCS-APIRequest": "true",
}
for k, v in key_values.items():
@ -274,20 +274,16 @@ class Nextcloud:
result = json.loads(
self._request("PUT", url, data=data, headers=headers)
)
# TODO: It seems like this only sets the first item in key_values
# This function probably doesn't do what it is supposed to
if result["ocs"]["meta"]["statuscode"] == 100:
return True
if result["ocs"]["meta"]["statuscode"] == 102:
raise ProviderItemExists
if result["ocs"]["meta"]["statuscode"] == 104:
raise ProviderGroupNotExists
if result["ocs"]["meta"]["statuscode"] != 100:
log.error("Get Nextcloud provider user add error: " + str(result))
raise ProviderOpError
except:
# log.error(traceback.format_exc())
raise
return False
return True
def add_user_to_group(self, userid : str, group_id : str) -> bool:
data = {"groupid": group_id}