Skip to content

Commit

Permalink
Merge pull request #252 from pastemyst/feat/pinned-pastes
Browse files Browse the repository at this point in the history
Feat/pinned pastes
  • Loading branch information
CodeMyst authored Mar 16, 2023
2 parents 4916431 + ddd6fad commit 552ace1
Show file tree
Hide file tree
Showing 20 changed files with 973 additions and 230 deletions.
6 changes: 6 additions & 0 deletions api/Controllers/PasteController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public async Task ToggleStarPaste(string pasteId)
await _pasteService.ToggleStarAsync(pasteId);
}

[HttpPost("{pasteId}/pin")]
public async Task TogglePinPaste(string pasteId)
{
await _pasteService.TogglePinnedAsync(pasteId);
}

[HttpPost]
public async Task<IActionResult> CreatePaste([FromBody] PasteCreateInfo createInfo)
{
Expand Down
8 changes: 7 additions & 1 deletion api/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public async Task<IActionResult> GetUser(string username, [FromQuery] string id)
[HttpGet("{username}/pastes")]
public async Task<Page<Paste>> GetUserOwnedPastes(string username, [FromQuery] PageRequest pageRequest)
{
return await _userProvider.GetOwnedPastesAsync(username, pageRequest);
return await _userProvider.GetOwnedPastesAsync(username, false, pageRequest);
}

[HttpGet("{username}/pastes/pinned")]
public async Task<Page<Paste>> GetUserOwnedPinnedPastes(string username, [FromQuery] PageRequest pageRequest)
{
return await _userProvider.GetOwnedPastesAsync(username, true, pageRequest);
}
}
247 changes: 247 additions & 0 deletions api/Migrations/20230314132209_PastePinned.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions api/Migrations/20230314132209_PastePinned.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace pastemyst.Migrations
{
/// <inheritdoc />
public partial class PastePinned : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "pinned",
table: "pastes",
type: "boolean",
nullable: false,
defaultValue: false);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "pinned",
table: "pastes");
}
}
}
Loading

0 comments on commit 552ace1

Please sign in to comment.