-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30467 from cdwcgt/friend-add
Add the ability to add/remove friends in `UserProfileHeader`
- Loading branch information
Showing
16 changed files
with
488 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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 AddFriendRequest : APIRequest<AddFriendResponse> | ||
{ | ||
public readonly int TargetId; | ||
|
||
public AddFriendRequest(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"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using Newtonsoft.Json; | ||
using osu.Game.Online.API.Requests.Responses; | ||
|
||
namespace osu.Game.Online.API.Requests | ||
{ | ||
public class AddFriendResponse | ||
{ | ||
[JsonProperty("user_relation")] | ||
public APIRelation UserRelation = null!; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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 DeleteFriendRequest : APIRequest | ||
{ | ||
public readonly int TargetId; | ||
|
||
public DeleteFriendRequest(int targetId) | ||
{ | ||
TargetId = targetId; | ||
} | ||
|
||
protected override WebRequest CreateWebRequest() | ||
{ | ||
var req = base.CreateWebRequest(); | ||
req.Method = HttpMethod.Delete; | ||
return req; | ||
} | ||
|
||
protected override string Target => $@"friends/{TargetId}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
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; } | ||
|
||
[JsonProperty("mutual")] | ||
public bool Mutual { get; set; } | ||
|
||
[JsonProperty("target")] | ||
public APIUser? TargetUser { get; set; } | ||
} | ||
|
||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum RelationType | ||
{ | ||
Friend, | ||
Block, | ||
} | ||
} |
Oops, something went wrong.