fix: remove notes count
This commit is contained in:
parent
2ce855d23c
commit
ed26870807
3 changed files with 15 additions and 12 deletions
|
@ -35,7 +35,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
id: ps.channelId,
|
id: ps.channelId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (channel == null) {
|
if (!channel) {
|
||||||
throw new ApiError(meta.errors.noSuchChannel);
|
throw new ApiError(meta.errors.noSuchChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { isUserRelated } from "@/misc/is-user-related.js";
|
||||||
import type { User } from "@/models/entities/user.js";
|
import type { User } from "@/models/entities/user.js";
|
||||||
import type { StreamMessages } from "../types.js";
|
import type { StreamMessages } from "../types.js";
|
||||||
import type { Packed } from "@/misc/schema.js";
|
import type { Packed } from "@/misc/schema.js";
|
||||||
|
import { scyllaClient } from "@/db/scylla.js";
|
||||||
|
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = "channel";
|
public readonly chName = "channel";
|
||||||
|
@ -45,7 +46,7 @@ export default class extends Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private onEvent(data: StreamMessages["channel"]["payload"]) {
|
private onEvent(data: StreamMessages["channel"]["payload"]) {
|
||||||
if (data.type === "typing") {
|
if (data.type === "typing" && !scyllaClient) {
|
||||||
const id = data.body;
|
const id = data.body;
|
||||||
const begin = !this.typers.has(id);
|
const begin = !this.typers.has(id);
|
||||||
this.typers.set(id, new Date());
|
this.typers.set(id, new Date());
|
||||||
|
|
|
@ -651,16 +651,18 @@ export default async (
|
||||||
lastNotedAt: new Date(),
|
lastNotedAt: new Date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
await Notes.countBy({
|
if (!scyllaClient) {
|
||||||
userId: user.id,
|
await Notes.countBy({
|
||||||
channelId: data.channel.id,
|
userId: user.id,
|
||||||
}).then((count) => {
|
channelId: data.channel.id,
|
||||||
// この処理が行われるのはノート作成後なので、ノートが一つしかなかったら最初の投稿だと判断できる
|
}).then((count) => {
|
||||||
// TODO: とはいえノートを削除して何回も投稿すればその分だけインクリメントされる雑さもあるのでどうにかしたい
|
// この処理が行われるのはノート作成後なので、ノートが一つしかなかったら最初の投稿だと判断できる
|
||||||
if (count === 1 && data.channel != null) {
|
// TODO: とはいえノートを削除して何回も投稿すればその分だけインクリメントされる雑さもあるのでどうにかしたい
|
||||||
Channels.increment({ id: data.channel.id }, "usersCount", 1);
|
if (count === 1 && data.channel != null) {
|
||||||
}
|
Channels.increment({ id: data.channel.id }, "usersCount", 1);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register to search database
|
// Register to search database
|
||||||
|
|
Loading…
Reference in a new issue