40 lines
No EOL
1.7 KiB
C#
40 lines
No EOL
1.7 KiB
C#
using Iceshrimp.Backend.Core.Database.Tables;
|
|
using Iceshrimp.Backend.Core.Events;
|
|
|
|
namespace Iceshrimp.Backend.Core.Services;
|
|
|
|
public class EventService
|
|
{
|
|
public event EventHandler<Note>? NotePublished;
|
|
public event EventHandler<Note>? NoteUpdated;
|
|
public event EventHandler<Note>? NoteDeleted;
|
|
public event EventHandler<NoteInteraction>? NoteLiked;
|
|
public event EventHandler<NoteInteraction>? NoteUnliked;
|
|
public event EventHandler<NoteReaction>? NoteReacted;
|
|
public event EventHandler<NoteReaction>? NoteUnreacted;
|
|
public event EventHandler<Notification>? Notification;
|
|
|
|
public void RaiseNotePublished(object? sender, Note note) => NotePublished?.Invoke(sender, note);
|
|
public void RaiseNoteUpdated(object? sender, Note note) => NoteUpdated?.Invoke(sender, note);
|
|
public void RaiseNoteDeleted(object? sender, Note note) => NoteDeleted?.Invoke(sender, note);
|
|
|
|
public void RaiseNotification(object? sender, Notification notification) =>
|
|
Notification?.Invoke(sender, notification);
|
|
|
|
public void RaiseNotifications(object? sender, IEnumerable<Notification> notifications)
|
|
{
|
|
foreach (var notification in notifications) Notification?.Invoke(sender, notification);
|
|
}
|
|
|
|
public void RaiseNoteLiked(object? sender, Note note, User user) =>
|
|
NoteLiked?.Invoke(sender, new NoteInteraction { Note = note, User = user });
|
|
|
|
public void RaiseNoteUnliked(object? sender, Note note, User user) =>
|
|
NoteUnliked?.Invoke(sender, new NoteInteraction { Note = note, User = user });
|
|
|
|
public void RaiseNoteReacted(object? sender, NoteReaction reaction) =>
|
|
NoteReacted?.Invoke(sender, reaction);
|
|
|
|
public void RaiseNoteUnreacted(object? sender, NoteReaction reaction) =>
|
|
NoteUnreacted?.Invoke(sender, reaction);
|
|
} |