Fix score, photo, and comment activities

This commit is contained in:
Slendy 2023-09-05 22:51:01 -05:00
commit 0c9c8fd7b2
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 27 additions and 7 deletions

View file

@ -196,6 +196,7 @@ public class ActivityEventHandlerTests
HeartedLevelId = 1, HeartedLevelId = 1,
UserId = 1, UserId = 1,
SlotId = 1, SlotId = 1,
Slot = slot,
}; };
eventHandler.OnEntityInserted(database, heartedLevel); eventHandler.OnEntityInserted(database, heartedLevel);

View file

@ -35,17 +35,35 @@ public class ActivityEntityEventHandler : IEntityEventHandler
}, },
_ => null, _ => null,
}, },
CommentEntity comment => comment.TargetSlot?.Type switch CommentEntity comment => comment.Type switch
{
CommentType.Level => comment.TargetSlot?.Type switch
{ {
SlotType.User => new CommentActivityEntity SlotType.User => new CommentActivityEntity
{ {
Type = comment.Type == CommentType.Level ? EventType.CommentOnLevel : EventType.CommentOnUser, Type = EventType.CommentOnLevel,
CommentId = comment.CommentId, CommentId = comment.CommentId,
UserId = comment.PosterUserId, UserId = comment.PosterUserId,
}, },
_ => null, _ => null,
}, },
PhotoEntity photo => photo.Slot?.Type switch CommentType.Profile => new CommentActivityEntity
{
Type = EventType.CommentOnUser,
CommentId = comment.CommentId,
UserId = comment.PosterUserId,
},
_ => null,
},
PhotoEntity photo => photo.SlotId switch
{
null => new PhotoActivityEntity
{
Type = EventType.UploadPhoto,
PhotoId = photo.PhotoId,
UserId = photo.CreatorId,
},
_ => photo.Slot?.Type switch
{ {
SlotType.User => new PhotoActivityEntity SlotType.User => new PhotoActivityEntity
{ {
@ -55,6 +73,7 @@ public class ActivityEntityEventHandler : IEntityEventHandler
}, },
_ => null, _ => null,
}, },
},
ScoreEntity score => score.Slot.Type switch ScoreEntity score => score.Slot.Type switch
{ {
// Don't add story scores or versus scores // Don't add story scores or versus scores