Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions PinkSea/Lexicons/Objects/Link.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Text.Json.Serialization;

namespace PinkSea.Lexicons.Objects;

/// <summary>
/// A profile link.
/// </summary>
public class Link
{
/// <summary>
/// The name of the link.
/// </summary>
[JsonPropertyName("name")]
public required string Name { get; set; }

/// <summary>
/// The url.
/// </summary>
[JsonPropertyName("url")]
public required string Url { get; set; }
}
15 changes: 15 additions & 0 deletions PinkSea/Lexicons/Queries/GetProfileQueryRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace PinkSea.Lexicons.Queries;

/// <summary>
/// The request for the "com.shinolabs.pinksea.unspecced.getProfile" xrpc call.
/// </summary>
public class GetProfileQueryRequest
{
/// <summary>
/// The DID of the user.
/// </summary>
[JsonPropertyName("did")]
public required string Did { get; set; }
}
46 changes: 46 additions & 0 deletions PinkSea/Lexicons/Queries/GetProfileQueryResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Text.Json.Serialization;
using PinkSea.Lexicons.Objects;

namespace PinkSea.Lexicons.Queries;

/// <summary>
/// The response for the "com.shinolabs.pinksea.unspecced.getProfile" xrpc query.
/// </summary>
public class GetProfileQueryResponse
{
/// <summary>
/// The DID of the user.
/// </summary>
[JsonPropertyName("did")]
public required string Did { get; set; }

/// <summary>
/// The handle of the user.
/// </summary>
[JsonPropertyName("handle")]
public required string Handle { get; set; }

/// <summary>
/// The nickname selected by the user.
/// </summary>
[JsonPropertyName("nick")]
public string? Nickname { get; set; }

/// <summary>
/// The URL of the avatar.
/// </summary>
[JsonPropertyName("avatar")]
public string? Avatar { get; set; }

/// <summary>
/// The description of this user.
/// </summary>
[JsonPropertyName("description")]
public string? Description { get; set; }

/// <summary>
/// The links this profile has.
/// </summary>
[JsonPropertyName("links")]
public IReadOnlyList<Link>? Links { get; set; }
}
50 changes: 50 additions & 0 deletions PinkSea/Xrpc/GetProfileQueryHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Microsoft.Extensions.Options;
using PinkSea.AtProto.Resolvers.Did;
using PinkSea.AtProto.Server.Xrpc;
using PinkSea.AtProto.Shared.Xrpc;
using PinkSea.Lexicons.Objects;
using PinkSea.Lexicons.Queries;
using PinkSea.Models;

namespace PinkSea.Xrpc;

/// <summary>
/// [UNSPECCED - DO NOT USE]
/// Handler for the "com.shinolabs.pinksea.unspecced.getProfile" query. Gets the profile information for a DID.
/// </summary>
[Xrpc("com.shinolabs.pinksea.unspecced.getProfile")]
public class GetProfileQueryHandler(
IDidResolver didResolver,
IOptions<AppViewConfig> opts) : IXrpcQuery<GetProfileQueryRequest, GetProfileQueryResponse>
{
/// <inheritdoc />
public async Task<XrpcErrorOr<GetProfileQueryResponse>> Handle(
GetProfileQueryRequest request)
{
var handle = await didResolver.GetHandleFromDid(request.Did);
if (string.IsNullOrEmpty(handle))
{
return XrpcErrorOr<GetProfileQueryResponse>.Fail(
"ProfileDoesntExist",
"This profile does not exist.");
}

// TODO: This is only a mock for iOSSea before we implement profile editing for realsies.
// Don't mind me being here!
var profile = new GetProfileQueryResponse
{
Did = request.Did,
Handle = handle,
Nickname = handle,
Description = "",
Links =
[
new Link { Name = "Bluesky", Url = $"https://bsky.app/profile/{request.Did}" },
new Link { Name = "Website", Url = $"https://{handle}" }
],
Avatar = $"{opts.Value.AppUrl}/blank_avatar.png"
};

return XrpcErrorOr<GetProfileQueryResponse>.Ok(profile);
}
}
Binary file added PinkSea/wwwroot/blank_avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.