Skip to content

Commit 2bd7c79

Browse files
committed
Merge branch 'hotfix/v1.2.1'
2 parents cb1636f + d61c6e7 commit 2bd7c79

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

API.Test/MessagesTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ public void GetStaffFilters()
102102
Assert.Fail();
103103
}
104104

105+
[Test]
106+
public void GetSearchedStaffPeople()
107+
{
108+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
109+
110+
Task<MessagePerson[]> filters = Client.GetStaffFilterSearchResultAsync("", new());
111+
filters.Wait();
112+
113+
if (filters.Result.Length > 0)
114+
Assert.Pass();
115+
else
116+
Assert.Fail();
117+
}
118+
105119
[Test]
106120
public void GetDrafts()
107121
{

WebUntisAPI.Client/WebUntisAPI.Client.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<Copyright>Copyright © Suiram1 2023</Copyright>
1717
<Description>A library in .NET to interact with the WebUntis API.</Description>
1818
<Company>Suiram1</Company>
19-
<AssemblyVersion>1.2.0</AssemblyVersion>
20-
<FileVersion>1.2.0</FileVersion>
21-
<Version>1.2.0</Version>
19+
<AssemblyVersion>1.2.1</AssemblyVersion>
20+
<FileVersion>1.2.1</FileVersion>
21+
<Version>1.2.1</Version>
2222
</PropertyGroup>
2323

2424
<ItemGroup>

WebUntisAPI.Client/WebUntisClient.Messages.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public async Task<MessagePerson[]> GetStaffFilterSearchResultAsync(string search
148148
{
149149
Method = HttpMethod.Post,
150150
RequestUri = new Uri(ServerUrl + $"/WebUntis/api/rest/view/v2/messages/recipients/STAFF/filter"),
151-
Content = new StringContent(sw.ToString())
151+
Content = new StringContent(sw.ToString(), Encoding.UTF8, "application/json")
152152
};
153153
request.Headers.Add("JSESSIONID", _sessionId);
154154
request.Headers.Add("schoolname", _schoolName);
@@ -169,7 +169,7 @@ public async Task<MessagePerson[]> GetStaffFilterSearchResultAsync(string search
169169
string responseString = await response.Content.ReadAsStringAsync();
170170

171171
JObject obj = JObject.Parse(responseString);
172-
return obj["users"].Value<List<MessagePerson>>().ToArray();
172+
return obj["users"].ToObject<List<MessagePerson>>().ToArray();
173173
}
174174

175175
/// <summary>

WebUntisAPI.Client/WebUntisclient.Profile.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public async Task<Image> GetMessagePersonProfileImageAsync(MessagePerson person,
131131

132132
#if NET47 || NET481
133133
Image image = Image.FromStream(await response.Content.ReadAsStreamAsync());
134-
134+
135135
if (image.Height == image.Width)
136136
return image;
137137

@@ -230,14 +230,14 @@ public async Task<GeneralAccount> GetGenerallyAccountInformationAsync(Cancellati
230230
/// <exception cref="HttpRequestException">Thrown when an error happened while the http request</exception>
231231
public async Task<(ContactDetails contact, bool canRead, bool canWrite)> GetContactDetailsAsync(CancellationToken ct = default)
232232
{
233-
string responseString = await MakeAPIGetRequestAsync($"/WebUntis/api/profile/contactdetails?personId={User.Id}&isRequestForStudent={UserType is Client.UserType.Student}", ct);
233+
string responseString = await MakeAPIGetRequestAsync($"/WebUntis/api/profile/contactdetails?personId={User.Id}&isRequestForStudent=false", ct);
234234
JObject data = JObject.Parse(responseString)["data"].Value<JObject>();
235235

236236
if (!data["read"].Value<bool>()) // Return null when you do not have a read permission
237237
return (null, false, data["write"].Value<bool>());
238238

239239
ContactDetails contact = data["address"].ToObject<ContactDetails>();
240-
return (contact, true, data["write"].Value<bool>());
240+
return (contact, data["read"].Value<bool>(), data["write"].Value<bool>());
241241
}
242242

243243
/// <summary>
@@ -289,7 +289,7 @@ public async Task<GeneralAccount> GetGenerallyAccountInformationAsync(Cancellati
289289
throw new HttpRequestException($"There was an error while the http request (Code: {response.StatusCode}).");
290290

291291
#if NET47 || NET481
292-
Image image = Image.FromStream(await response.Content.ReadAsStreamAsync());
292+
Image image = Image.FromStream(await response.Content.ReadAsStreamAsync());
293293
#elif NET6_0_OR_GREATER
294294
Image image = await Image.LoadAsync(await response.Content.ReadAsStreamAsync(ct), ct);
295295
#endif

0 commit comments

Comments
 (0)