summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/ReactionService.ts
diff options
context:
space:
mode:
authorCyberRex <hspwinx86@gmail.com>2022-12-21 10:23:03 +0900
committerGitHub <noreply@github.com>2022-12-21 10:23:03 +0900
commitfe158339da85c0dc9674509d416d132435cbbdcf (patch)
treed94d5fde856aa4ec77b426ef040a98980a82a001 /packages/backend/src/core/ReactionService.ts
parent13.0.0-alpha.2 (diff)
downloadsharkey-fe158339da85c0dc9674509d416d132435cbbdcf.tar.gz
sharkey-fe158339da85c0dc9674509d416d132435cbbdcf.tar.bz2
sharkey-fe158339da85c0dc9674509d416d132435cbbdcf.zip
improve(backend): Skip note score incrementing when bots reacted (#9367)
fix Improved code quality fix small fix
Diffstat (limited to 'packages/backend/src/core/ReactionService.ts')
-rw-r--r--packages/backend/src/core/ReactionService.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts
index 09022b57ab..1775d54228 100644
--- a/packages/backend/src/core/ReactionService.ts
+++ b/packages/backend/src/core/ReactionService.ts
@@ -83,7 +83,7 @@ export class ReactionService {
}
@bindThis
- public async create(user: { id: User['id']; host: User['host']; }, note: Note, reaction?: string) {
+ public async create(user: { id: User['id']; host: User['host']; isBot: User['isBot'] }, note: Note, reaction?: string) {
// Check blocking
if (note.userId !== user.id) {
const block = await this.blockingsRepository.findOneBy({
@@ -139,7 +139,7 @@ export class ReactionService {
await this.notesRepository.createQueryBuilder().update()
.set({
reactions: () => sql,
- score: () => '"score" + 1',
+ ... (!user.isBot ? { score: () => '"score" + 1' } : {}),
})
.where('id = :id', { id: note.id })
.execute();
@@ -199,7 +199,7 @@ export class ReactionService {
}
@bindThis
- public async delete(user: { id: User['id']; host: User['host']; }, note: Note) {
+ public async delete(user: { id: User['id']; host: User['host']; isBot: User['isBot']; }, note: Note) {
// if already unreacted
const exist = await this.noteReactionsRepository.findOneBy({
noteId: note.id,
@@ -226,7 +226,7 @@ export class ReactionService {
.where('id = :id', { id: note.id })
.execute();
- this.notesRepository.decrement({ id: note.id }, 'score', 1);
+ if (!user.isBot) this.notesRepository.decrement({ id: note.id }, 'score', 1);
this.globalEventServie.publishNoteStream(note.id, 'unreacted', {
reaction: this.decodeReaction(exist.reaction).reaction,