hippofish/packages/backend/src/services/add-note-to-antenna.ts

25 lines
626 B
TypeScript
Raw Normal View History

2023-01-13 05:40:33 +01:00
import type { Antenna } from "@/models/entities/antenna.js";
import type { Note } from "@/models/entities/note.js";
2023-08-06 08:34:44 +02:00
import { getTimestamp } from "@/misc/gen-id.js";
import { redisClient } from "@/db/redis.js";
import { publishAntennaStream } from "@/services/stream.js";
2023-01-13 05:40:33 +01:00
import type { User } from "@/models/entities/user.js";
export async function addNoteToAntenna(
antenna: Antenna,
note: Note,
_noteUser: { id: User["id"] },
2023-01-13 05:40:33 +01:00
) {
redisClient.xadd(
`antennaTimeline:${antenna.id}`,
"MAXLEN",
"~",
"200",
2023-08-06 08:34:44 +02:00
`${getTimestamp(note.id)}-*`,
"note",
note.id,
);
2023-01-13 05:40:33 +01:00
publishAntennaStream(antenna.id, "note", note);
}