account deletion & minor changes#14
Closed
Camper-CoolDie wants to merge 4 commits intotimas130:masterfrom
Closed
Conversation
timas130
requested changes
Feb 9, 2025
CampfireSDK/src/main/java/com/sayzen/campfiresdk/controllers/ControllerPost.kt
Outdated
Show resolved
Hide resolved
CampfireSDK/src/main/java/com/sayzen/campfiresdk/models/splashs/SplashAdminAccountRemove.kt
Outdated
Show resolved
Hide resolved
CampfireServer/src/main/java/com/dzen/campfire/server/controllers/ControllerAccounts.kt
Show resolved
Hide resolved
For some reason the old version was deleted from https://jitpack.io
timas130
requested changes
Mar 9, 2025
| val imageTitleId: Long = v.next() | ||
| val imageTitleGifId: Long = v.next() | ||
|
|
||
| RustAuth.delete(accountId) |
Owner
There was a problem hiding this comment.
Лучше не удалять аккаунт прям полностью из базы данных. Лучше "анонимизировать" его, просто переименовав в deleted#[ID]. Таким образом другие упоминания удалённого пользователя не сломают сервер.
Comment on lines
+338
to
+390
| val selectComments = ControllerPublications.instanceSelect(0) | ||
| .where(TPublications.publication_type, "=", API.PUBLICATION_TYPE_COMMENT) | ||
| .where(TPublications.creator_id, "=", accountId) | ||
| val comments = ControllerPublications.parseSelect(Database.select("ControllerAccounts.remove.removeComments", selectComments)) | ||
|
|
||
| val selectMessages = ControllerPublications.instanceSelect(0) | ||
| .where(TPublications.publication_type, "=", API.PUBLICATION_TYPE_CHAT_MESSAGE) | ||
| .where(TPublications.creator_id, "=", accountId) | ||
| val messages = ControllerPublications.parseSelect(Database.select("ControllerAccounts.remove.removeMessages", selectMessages)) | ||
|
|
||
| // remove all stickers' resources | ||
| val selectStickerPacks = ControllerPublications.instanceSelect(0) | ||
| .where(TPublications.publication_type, "=", API.PUBLICATION_TYPE_STICKERS_PACK) | ||
| .where(TPublications.creator_id, "=", accountId) | ||
| val stickerPacks = ControllerPublications.parseSelect(Database.select("ControllerAccounts.remove.removeStickerPacks", selectStickerPacks)) | ||
| for (pack in stickerPacks) { | ||
| val stickers = ControllerPublications.parseSelect( | ||
| Database.select("ControllerAccounts.remove.removeStickerPacks select", ControllerPublications.instanceSelect(0) | ||
| .where(TPublications.tag_1, "=", pack.id) | ||
| .where(TPublications.publication_type, "=", API.PUBLICATION_TYPE_STICKER)) | ||
| ) | ||
| for (sticker in stickers) { | ||
| sticker as PublicationSticker | ||
| ControllerResources.remove(sticker.imageId) | ||
| ControllerResources.remove(sticker.gifId) | ||
| } | ||
| } | ||
|
|
||
| // remove all post pages' resources | ||
| val selectPosts = ControllerPublications.instanceSelect(0) | ||
| .where(TPublications.publication_type, "=", API.PUBLICATION_TYPE_POST) | ||
| .where(TPublications.creator_id, "=", accountId) | ||
| val posts = ControllerPublications.parseSelect(Database.select("ControllerAccounts.remove.removePostPages", selectPosts)) | ||
| for (post in posts) { | ||
| post as PublicationPost | ||
| for (page in post.pages) ControllerPost.removePage(page) | ||
| } | ||
|
|
||
| Database.remove("ControllerAccounts.remove.removePublications", SqlQueryRemove(TPublications.NAME) | ||
| .where(TPublications.creator_id, "=", accountId)) | ||
|
|
||
| // some things need to be updated after publications have been removed | ||
|
|
||
| for (comment in comments) { | ||
| Database.update("ControllerAccounts.remove.removeComments update", SqlQueryUpdate(TPublications.NAME) | ||
| .where(TPublications.id, "=", comment.parentPublicationId) | ||
| .update(TPublications.subpublications_count, TPublications.subpublications_count + "-1")) | ||
| ControllerPublications.recountBestComment(comment.parentPublicationId, comment.id) | ||
| } | ||
|
|
||
| for (message in messages) { | ||
| ControllerChats.onMessagesRemoved((message as PublicationChatMessage).chatTag(), 1) | ||
| } |
Owner
There was a problem hiding this comment.
Не, совсем фигово получается. Допустим у человека будет под 20к сообщений (есть такие), тогда при удалении встанет чуть ли не всё. Можно какую-нибудь локальную extension function на Database, которая итерирует над строками, а сама подгружает их по штук 100. Для вещей внизу, которые должны обновиться после удаления публикаций, можно просто хранить нужные данные во вспомогательном списке.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ControllerAccounts.delete()(улучшение рейтингов сделаю, но позже)