-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to add/remove friends in UserProfileHeader
#30467
Changes from 9 commits
bf53833
69b5bd3
350e1d6
45cc830
0b2f4fa
29ba13f
b682285
3bd116c
9e4c382
729c7f1
21b1c79
fbe6077
1a92e5a
cb83300
e064965
0087270
1fcdf67
c576fd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
bdach marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Net.Http; | ||
using osu.Framework.IO.Network; | ||
using osu.Game.Online.API.Requests.Responses; | ||
|
||
namespace osu.Game.Online.API.Requests | ||
{ | ||
public class FriendAddRequest : APIRequest<APIRelation> | ||
{ | ||
public readonly int TargetId; | ||
|
||
public FriendAddRequest(int targetId) | ||
{ | ||
TargetId = targetId; | ||
} | ||
|
||
protected override WebRequest CreateWebRequest() | ||
{ | ||
var req = base.CreateWebRequest(); | ||
|
||
req.Method = HttpMethod.Post; | ||
req.AddParameter("target", TargetId.ToString(), RequestParameterType.Query); | ||
|
||
return req; | ||
} | ||
|
||
protected override string Target => @"friends"; | ||
} | ||
} |
bdach marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Net.Http; | ||
using osu.Framework.IO.Network; | ||
|
||
namespace osu.Game.Online.API.Requests | ||
{ | ||
public class FriendDeleteRequest : APIRequest | ||
{ | ||
public readonly int TargetId; | ||
|
||
public FriendDeleteRequest(int targetId) | ||
{ | ||
TargetId = targetId; | ||
} | ||
|
||
protected override WebRequest CreateWebRequest() | ||
{ | ||
var req = base.CreateWebRequest(); | ||
req.Method = HttpMethod.Delete; | ||
return req; | ||
} | ||
|
||
protected override string Target => $@"friends/{TargetId}"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
namespace osu.Game.Online.API.Requests | ||
{ | ||
public class GetFriendsRequest : APIRequest<List<APIUser>> | ||
public class GetFriendsRequest : APIRequest<List<APIRelation>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this works because API-side the format of the response is changed and is dependent on |
||
{ | ||
protected override string Target => @"friends"; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace osu.Game.Online.API.Requests.Responses | ||
{ | ||
public class APIRelation | ||
{ | ||
[JsonProperty("target_id")] | ||
public int TargetID { get; set; } | ||
|
||
[JsonProperty("relation_type")] | ||
public RelationType RelationType { get; set; } | ||
bdach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[JsonProperty("mutual")] | ||
public bool Mutual { get; set; } | ||
|
||
[JsonProperty("target")] | ||
public APIUser? TargetUser { get; set; } | ||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this field referenced from? It's not in https://github.com/nanaya/osu-web/blob/c029567dce89fd68446f56e40870c3cec01d7591/resources/js/interfaces/user-relation-json.ts#L4-L8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But he does exist, I think it's this is in api will return APIUser when request friends but not for block relation |
||
} | ||
|
||
public enum RelationType | ||
{ | ||
Friend, | ||
Block, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to preceding comment - if the need to refetch users can be removed, this method probably doesn't need to exist. (I guess there is #13604, but it's (a) out of scope here, and (b) not even a given that a poll like the OP of that proposes is the right thing to do.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll keep him for now until the results come in?