-
Notifications
You must be signed in to change notification settings - Fork 136
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 #802 from EdiWang/dev/webmention
Webmention Phase 1: Shared Infrastructure
- Loading branch information
Showing
37 changed files
with
321 additions
and
236 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,10 @@ | ||
-- v14.3.x - v14.4.0 | ||
CREATE TABLE [dbo].[LoginHistory]( | ||
[Id] [int] IDENTITY(1,1) NOT NULL, | ||
[LoginTimeUtc] [datetime] NOT NULL, | ||
[LoginIp] [nvarchar](64) NULL, | ||
[LoginUserAgent] [nvarchar](128) NULL, | ||
[DeviceFingerprint] [nvarchar](128) NULL, | ||
CONSTRAINT [PK_LoginHistory] PRIMARY KEY CLUSTERED | ||
( | ||
[Id] ASC | ||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] | ||
) ON [PRIMARY] | ||
GO | ||
-- v14.4.1 - v14.5.x | ||
|
||
DROP TABLE [LocalAccount] | ||
EXEC sp_rename 'Pingback', 'Mention' | ||
GO | ||
|
||
EXEC sys.sp_rename | ||
@objname = N'Category.RouteName', | ||
@newname = 'Slug', | ||
@objtype = 'COLUMN' | ||
ALTER TABLE Mention ADD Worker NVARCHAR(16) | ||
GO | ||
|
||
IF EXISTS ( | ||
SELECT 1 | ||
FROM sys.columns c | ||
JOIN sys.objects o ON c.object_id = o.object_id | ||
WHERE o.name = 'Post' AND c.name = 'InlineCss' | ||
) | ||
BEGIN | ||
ALTER TABLE Post DROP COLUMN InlineCss; | ||
END; | ||
GO | ||
UPDATE Mention SET Worker = N'Pingback' | ||
GO |
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
15 changes: 15 additions & 0 deletions
15
src/Moonglade.Data.MySql/Configurations/MentionConfiguration.cs
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,15 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Moonglade.Data.Entities; | ||
|
||
namespace Moonglade.Data.MySql.Configurations; | ||
|
||
|
||
internal class MentionConfiguration : IEntityTypeConfiguration<MentionEntity> | ||
{ | ||
public void Configure(EntityTypeBuilder<MentionEntity> builder) | ||
{ | ||
builder.Property(e => e.Id).ValueGeneratedNever(); | ||
builder.Property(e => e.PingTimeUtc).HasColumnType("datetime"); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/Moonglade.Data.MySql/Configurations/PingbackConfiguration.cs
This file was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
src/Moonglade.Data.PostgreSql/Configurations/MentionConfiguration.cs
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,15 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Moonglade.Data.Entities; | ||
|
||
namespace Moonglade.Data.PostgreSql.Configurations; | ||
|
||
|
||
internal class MentionConfiguration : IEntityTypeConfiguration<MentionEntity> | ||
{ | ||
public void Configure(EntityTypeBuilder<MentionEntity> builder) | ||
{ | ||
builder.Property(e => e.Id).ValueGeneratedNever(); | ||
builder.Property(e => e.PingTimeUtc).HasColumnType("timestamp"); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/Moonglade.Data.PostgreSql/Configurations/PingbackConfiguration.cs
This file was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
src/Moonglade.Data.SqlServer/Configurations/MentionConfiguration.cs
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,15 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Moonglade.Data.Entities; | ||
|
||
namespace Moonglade.Data.SqlServer.Configurations; | ||
|
||
|
||
internal class MentionConfiguration : IEntityTypeConfiguration<MentionEntity> | ||
{ | ||
public void Configure(EntityTypeBuilder<MentionEntity> builder) | ||
{ | ||
builder.Property(e => e.Id).ValueGeneratedNever(); | ||
builder.Property(e => e.PingTimeUtc).HasColumnType("datetime"); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/Moonglade.Data.SqlServer/Configurations/PingbackConfiguration.cs
This file was deleted.
Oops, something went wrong.
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
20 changes: 18 additions & 2 deletions
20
...Moonglade.Data/Entities/PingbackEntity.cs → src/Moonglade.Data/Entities/MentionEntity.cs
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 |
---|---|---|
@@ -1,13 +1,29 @@ | ||
namespace Moonglade.Data.Entities; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
public class PingbackEntity | ||
namespace Moonglade.Data.Entities; | ||
|
||
public class MentionEntity | ||
{ | ||
public Guid Id { get; set; } | ||
|
||
[MaxLength(256)] | ||
public string Domain { get; set; } | ||
|
||
[MaxLength(256)] | ||
public string SourceUrl { get; set; } | ||
|
||
[MaxLength(256)] | ||
public string SourceTitle { get; set; } | ||
|
||
[MaxLength(64)] | ||
public string SourceIp { get; set; } | ||
|
||
public Guid TargetPostId { get; set; } | ||
public DateTime PingTimeUtc { get; set; } | ||
|
||
[MaxLength(100)] | ||
public string TargetPostTitle { get; set; } | ||
|
||
[MaxLength(16)] | ||
public string Worker { get; set; } | ||
} |
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,12 @@ | ||
using MediatR; | ||
using Moonglade.Data; | ||
using Moonglade.Data.Entities; | ||
|
||
namespace Moonglade.Mention.Common; | ||
|
||
public record ClearMentionsCommand : IRequest; | ||
|
||
public class ClearPingbackCommandHandler(MoongladeRepository<MentionEntity> repo) : IRequestHandler<ClearMentionsCommand> | ||
{ | ||
public Task Handle(ClearMentionsCommand request, CancellationToken ct) => repo.Clear(ct); | ||
} |
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,19 @@ | ||
using MediatR; | ||
using Moonglade.Data; | ||
using Moonglade.Data.Entities; | ||
|
||
namespace Moonglade.Mention.Common; | ||
|
||
public record DeleteMentionCommand(Guid Id) : IRequest; | ||
|
||
public class DeletePingbackCommandHandler(MoongladeRepository<MentionEntity> repo) : IRequestHandler<DeleteMentionCommand> | ||
{ | ||
public async Task Handle(DeleteMentionCommand request, CancellationToken ct) | ||
{ | ||
var entity = await repo.GetByIdAsync(request.Id, ct); | ||
if (entity != null) | ||
{ | ||
await repo.DeleteAsync(entity, ct); | ||
} | ||
} | ||
} |
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,15 @@ | ||
using MediatR; | ||
using Moonglade.Data; | ||
using Moonglade.Data.Entities; | ||
using Moonglade.Data.Specifications; | ||
|
||
namespace Moonglade.Mention.Common; | ||
|
||
public record GetMentionsQuery : IRequest<List<MentionEntity>>; | ||
|
||
public class GetMentionsQueryHandler(MoongladeRepository<MentionEntity> repo) : | ||
IRequestHandler<GetMentionsQuery, List<MentionEntity>> | ||
{ | ||
public Task<List<MentionEntity>> Handle(GetMentionsQuery request, CancellationToken ct) => | ||
repo.ListAsync(new MentionReadOnlySpec(), ct); | ||
} |
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
Oops, something went wrong.