mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-05 22:35:17 -04:00
Social interactions with annotations (#4068)
Co-authored-by: Joe Milazzo <josephmajora@gmail.com>
This commit is contained in:
@@ -42,6 +42,16 @@ public class UsersController : BaseApiController
|
||||
public async Task<ActionResult> DeleteUser(string username)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(username);
|
||||
if (user == null) return BadRequest();
|
||||
|
||||
// Remove all likes for the user, so like counts are correct
|
||||
var annotations = await _unitOfWork.AnnotationRepository.GetAllAnnotations();
|
||||
foreach (var annotation in annotations.Where(a => a.Likes.Contains(user.Id)))
|
||||
{
|
||||
annotation.Likes.Remove(user.Id);
|
||||
_unitOfWork.AnnotationRepository.Update(annotation);
|
||||
}
|
||||
|
||||
_unitOfWork.UserRepository.Delete(user);
|
||||
|
||||
//(TODO: After updating a role or removing a user, delete their token)
|
||||
@@ -108,10 +118,16 @@ public class UsersController : BaseApiController
|
||||
existingPreferences.PromptForDownloadSize = preferencesDto.PromptForDownloadSize;
|
||||
existingPreferences.NoTransitions = preferencesDto.NoTransitions;
|
||||
existingPreferences.CollapseSeriesRelationships = preferencesDto.CollapseSeriesRelationships;
|
||||
existingPreferences.ShareReviews = preferencesDto.ShareReviews;
|
||||
existingPreferences.ColorScapeEnabled = preferencesDto.ColorScapeEnabled;
|
||||
existingPreferences.BookReaderHighlightSlots = preferencesDto.BookReaderHighlightSlots;
|
||||
|
||||
var allLibs = (await _unitOfWork.LibraryRepository.GetLibrariesForUserIdAsync(user.Id))
|
||||
.Select(l => l.Id).ToList();
|
||||
|
||||
preferencesDto.SocialPreferences.SocialLibraries = preferencesDto.SocialPreferences.SocialLibraries
|
||||
.Where(l => allLibs.Contains(l)).ToList();
|
||||
existingPreferences.SocialPreferences = preferencesDto.SocialPreferences;
|
||||
|
||||
if (await _licenseService.HasActiveLicense())
|
||||
{
|
||||
existingPreferences.AniListScrobblingEnabled = preferencesDto.AniListScrobblingEnabled;
|
||||
|
||||
Reference in New Issue
Block a user