Skip to content

Implement comment API endpoints - #917

Merged
jvyden merged 8 commits into
LittleBigRefresh:mainfrom
Toastbrot236:comment-api
Aug 4, 2025
Merged

Implement comment API endpoints#917
jvyden merged 8 commits into
LittleBigRefresh:mainfrom
Toastbrot236:comment-api

Conversation

@Toastbrot236

@Toastbrot236 Toastbrot236 commented Aug 2, 2025

Copy link
Copy Markdown
Contributor

This implements API endpoints for getting a level/profile comment by ID, a list of them on a level/profile, deleting a comment as its poster/level publisher/profile owner, and rating comments.
Also implements a few tests for these endpoints and introduces ApiMinimalUserResponse and ApiMinimalLevelResponse to not include entire user/level objects for every single comment (and just enough to show a level/user's name and icon on the frontend).
These "minimal" classes might be more efficient here, considering that lists of comments might contain the same user/level objects multiple times and the frontend probably wouldn't be able to show much about them and the user probably wouldn't want to know much about them at that point anyway. Could probably also use them for reviews and playlists later on once those get implemented and for some already implemented responses like levels and photos in APIv4 in the future, for example.

This closes issue #424

@jvyden
jvyden self-requested a review August 3, 2025 19:19
Comment on lines +15 to +17
public required int YayRatings { get; set; }
public required int BooRatings { get; set; }
public required int OwnRating { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a statistics object?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might make sense, could probably reuse them for reviews later too.

{
public required int CommentId { get; set; }
public required string Content { get; set; }
public required ApiMinimalUserResponse Poster { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Publisher is more consistent. Unless you want to change the model name too, in which case I think Author works better

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Publisher is better I think.

namespace Refresh.Interfaces.APIv3.Endpoints.DataTypes.Response.Comments;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class ApiProfileCommentResponse : IApiResponse, IDataConvertableFrom<ApiProfileCommentResponse, GameProfileComment>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto concerns for this class as well

}

[ApiV3Endpoint("profileComments/id/{id}"), Authentication(false)]
[DocSummary("Gets the profile comment specified by it's ID.")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DocSummary("Gets the profile comment specified by it's ID.")]
[DocSummary("Gets the profile comment specified by its ID.")]

}

[ApiV3Endpoint("profileComments/id/{id}", HttpMethods.Delete)]
[DocSummary("Deletes the profile comment specified by it's ID. Fails if the user is not the comment poster or the profile owner.")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DocSummary("Deletes the profile comment specified by it's ID. Fails if the user is not the comment poster or the profile owner.")]
[DocSummary("Deletes the profile comment specified by its ID. Fails if the user is not the comment poster or the profile owner.")]

Comment thread Refresh.Interfaces.APIv3/Endpoints/CommentApiEndpoints.cs

(int skip, int count) = context.GetPageData();

DatabaseList<GameLevelComment>? comments = dataContext.Database.GetLevelComments(level, count, skip);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't ever be null

Suggested change
DatabaseList<GameLevelComment>? comments = dataContext.Database.GetLevelComments(level, count, skip);
DatabaseList<GameLevelComment> comments = dataContext.Database.GetLevelComments(level, count, skip);


(int skip, int count) = context.GetPageData();

DatabaseList<GameProfileComment>? comments = dataContext.Database.GetProfileComments(profile, count, skip);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DatabaseList<GameProfileComment>? comments = dataContext.Database.GetProfileComments(profile, count, skip);
DatabaseList<GameProfileComment> comments = dataContext.Database.GetProfileComments(profile, count, skip);

@Toastbrot236
Toastbrot236 requested a review from jvyden August 4, 2025 09:47
@jvyden
jvyden merged commit cb3d509 into LittleBigRefresh:main Aug 4, 2025
3 checks passed
@Toastbrot236
Toastbrot236 deleted the comment-api branch August 5, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants