diff --git a/MattermostApi/Api.cs b/MattermostApi/Api.cs index 1009f72..8690605 100644 --- a/MattermostApi/Api.cs +++ b/MattermostApi/Api.cs @@ -289,7 +289,7 @@ public async Task RefreshAsync() { }); Log(result.ToString()); Token token = result.ToObject(); - if (!string.IsNullOrEmpty(token.access_token)) + if (string.IsNullOrEmpty(token.access_token)) throw new ApiException("No access token returned", result); updateToken(token); } diff --git a/MattermostApi/Channel.cs b/MattermostApi/Channel.cs index ff6c3bd..87f78d1 100644 --- a/MattermostApi/Channel.cs +++ b/MattermostApi/Channel.cs @@ -115,6 +115,13 @@ public async Task UpdateRoles(Api api, string user_id, string roles) { }); } + public async Task UpdateRoles(Api api, string userId, bool scheme_admin, bool scheme_user = true) { + await api.PutAsync(Api.Combine("channels", id, "members", userId, "schemeRoles"), null, new { + scheme_admin, + scheme_user + }); + } + public async Task UpdateNotifications(Api api, string user_id, ChannelNotifyProps notifications) { await api.PutAsync(Api.Combine("channels", id, "members", user_id, "notify_props"), null, notifications); } diff --git a/MattermostApi/MattermostApi.csproj b/MattermostApi/MattermostApi.csproj index 59aa9fe..4727fe4 100644 --- a/MattermostApi/MattermostApi.csproj +++ b/MattermostApi/MattermostApi.csproj @@ -12,8 +12,8 @@ https://github.com/nikkilocke/MattermostApi https://github.com/nikkilocke/MattermostApi GitHub - Set CSRF cookie so login with username and password can PUT, DELETE and POST. - 1.0.4 + Added update scheme-derived roles + 1.0.5 diff --git a/MattermostApi/Team.cs b/MattermostApi/Team.cs index 8b01b92..c6cea7a 100644 --- a/MattermostApi/Team.cs +++ b/MattermostApi/Team.cs @@ -97,5 +97,18 @@ public async Task AddUser(Api api, string user_id) { user_id }); } + + public async Task UpdateRoles(Api api, string user_id, string roles) { + await api.PutAsync(Api.Combine("teams", id, "members", user_id, "roles"), null, new { + roles + }); + } + + public async Task UpdateRoles(Api api, string userId, bool scheme_admin, bool scheme_user = true) { + await api.PutAsync(Api.Combine("teams", id, "members", userId, "schemeRoles"), null, new { + scheme_admin, + scheme_user + }); + } } }