a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend] Restrict interactions with unpublished notes

Kopper be27d75a 0b001746

+22 -2
+22 -2
Iceshrimp.Backend/Core/Services/NoteService.cs
··· 893 893 await db.SaveChangesAsync(); 894 894 eventSvc.RaiseNoteUpdated(note); 895 895 896 - if (!isEdit) return note; 896 + if (!note.Published || !isEdit) return note; 897 897 898 - await notificationSvc.GenerateMentionNotificationsAsync(note, mentionedLocalUserIds); 898 + await notificationSvc.GenerateMentionNotificationsAsync(note, mentionedLocalUserIds); 899 899 await notificationSvc.GenerateEditNotificationsAsync(note); 900 900 901 901 if (note.LocalOnly || note.User.IsRemoteUser) return note; ··· 926 926 eventSvc.RaiseNoteDeleted(note); 927 927 await db.SaveChangesAsync(); 928 928 await UpdateNoteCountersAsync(note, false); 929 + 930 + if (!note.Published) return; 929 931 930 932 if (note.User.IsRemoteUser) 931 933 { ··· 1578 1580 { 1579 1581 if (note.IsPureRenote) 1580 1582 throw GracefulException.BadRequest("Cannot like a pure renote"); 1583 + 1584 + if (!note.Published) 1585 + throw GracefulException.BadRequest("This note has not been published yet"); 1581 1586 1582 1587 if (!await db.NoteLikes.AnyAsync(p => p.Note == note && p.User == user)) 1583 1588 { ··· 1613 1618 1614 1619 public async Task<bool> UnlikeNoteAsync(Note note, User user) 1615 1620 { 1621 + if (!note.Published) 1622 + throw GracefulException.BadRequest("This note has not been published yet"); 1623 + 1616 1624 var like = await db.NoteLikes.Where(p => p.Note == note && p.User == user).FirstOrDefaultAsync(); 1617 1625 if (like == null) return false; 1618 1626 db.Remove(like); ··· 1640 1648 1641 1649 public async Task<Note?> RenoteNoteAsync(Note note, User user, Note.NoteVisibility? visibility = null) 1642 1650 { 1651 + if (!note.Published) 1652 + throw GracefulException.BadRequest("This note has not been published yet"); 1653 + 1643 1654 visibility ??= user.UserSettings?.DefaultRenoteVisibility ?? Note.NoteVisibility.Public; 1644 1655 if (visibility == Note.NoteVisibility.Specified) 1645 1656 throw GracefulException.BadRequest("Renote visibility must be one of: public, unlisted, private"); ··· 1717 1728 { 1718 1729 if (user.IsRemoteUser) throw new Exception("This method is only valid for local users"); 1719 1730 1731 + if (!note.Published) 1732 + throw GracefulException.BadRequest("This note has not been published yet"); 1720 1733 if (note.IsPureRenote) 1721 1734 throw GracefulException.BadRequest("Cannot pin a pure renote"); 1722 1735 if (note.User != user) ··· 1752 1765 public async Task UnpinNoteAsync(Note note, User user) 1753 1766 { 1754 1767 if (user.IsRemoteUser) throw new Exception("This method is only valid for local users"); 1768 + if (!note.Published) 1769 + throw GracefulException.BadRequest("This note has not been published yet"); 1755 1770 1756 1771 var count = await db.UserNotePins.Where(p => p.Note == note && p.User == user).ExecuteDeleteAsync(); 1757 1772 if (count == 0) return; ··· 1821 1836 1822 1837 public async Task<(string name, bool success)> ReactToNoteAsync(Note note, User user, string name) 1823 1838 { 1839 + if (!note.Published) 1840 + throw GracefulException.BadRequest("This note has not been published yet"); 1824 1841 if (note.IsPureRenote) 1825 1842 throw GracefulException.BadRequest("Cannot react to a pure renote"); 1826 1843 ··· 1870 1887 1871 1888 public async Task<(string name, bool success)> RemoveReactionFromNoteAsync(Note note, User user, string name) 1872 1889 { 1890 + if (!note.Published) 1891 + throw GracefulException.BadRequest("This note has not been published yet"); 1892 + 1873 1893 name = await emojiSvc.ResolveEmojiNameAsync(name, user.Host); 1874 1894 1875 1895 var reaction =