Skip to content

Commit

Permalink
Fixed bug in RefreshAsync.
Browse files Browse the repository at this point in the history
Added update scheme-derived roles.
  • Loading branch information
nikkilocke committed Aug 9, 2019
1 parent af11f84 commit 51477a3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MattermostApi/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public async Task RefreshAsync() {
});
Log(result.ToString());
Token token = result.ToObject<Token>();
if (!string.IsNullOrEmpty(token.access_token))
if (string.IsNullOrEmpty(token.access_token))
throw new ApiException("No access token returned", result);
updateToken(token);
}
Expand Down
7 changes: 7 additions & 0 deletions MattermostApi/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions MattermostApi/MattermostApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<PackageProjectUrl>https://github.com/nikkilocke/MattermostApi</PackageProjectUrl>
<RepositoryUrl>https://github.com/nikkilocke/MattermostApi</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageReleaseNotes>Set CSRF cookie so login with username and password can PUT, DELETE and POST.</PackageReleaseNotes>
<Version>1.0.4</Version>
<PackageReleaseNotes>Added update scheme-derived roles</PackageReleaseNotes>
<Version>1.0.5</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions MattermostApi/Team.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,18 @@ public async Task<UserInTeam> 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
});
}
}
}

0 comments on commit 51477a3

Please sign in to comment.