4ca445b587
This PR contains new source for antenna posts, which is a list of instance hostnames to process all posts from. Using this mode, a user can filter for keywords on an instance wide basis. This change includes a new antenna source called `instances` and a new database column in the `antenna` table called `instances` to store the instance names. On the antenna editor, there's also an "Add an instance" finder dialog to allow users to search through the known instance hostnames. Co-authored-by: Kaity A <supakaity@blahaj.zone> Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9604 Co-authored-by: Kaity A <supakaity@noreply.codeberg.org> Co-committed-by: Kaity A <supakaity@noreply.codeberg.org>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { db } from "@/db/postgre.js";
|
|
import { Antenna } from "@/models/entities/antenna.js";
|
|
import type { Packed } from "@/misc/schema.js";
|
|
import { AntennaNotes, UserGroupJoinings } from "../index.js";
|
|
|
|
export const AntennaRepository = db.getRepository(Antenna).extend({
|
|
async pack(src: Antenna["id"] | Antenna): Promise<Packed<"Antenna">> {
|
|
const antenna =
|
|
typeof src === "object" ? src : await this.findOneByOrFail({ id: src });
|
|
|
|
const hasUnreadNote =
|
|
(await AntennaNotes.findOneBy({ antennaId: antenna.id, read: false })) !=
|
|
null;
|
|
const userGroupJoining = antenna.userGroupJoiningId
|
|
? await UserGroupJoinings.findOneBy({ id: antenna.userGroupJoiningId })
|
|
: null;
|
|
|
|
return {
|
|
id: antenna.id,
|
|
createdAt: antenna.createdAt.toISOString(),
|
|
name: antenna.name,
|
|
keywords: antenna.keywords,
|
|
excludeKeywords: antenna.excludeKeywords,
|
|
src: antenna.src,
|
|
userListId: antenna.userListId,
|
|
userGroupId: userGroupJoining ? userGroupJoining.userGroupId : null,
|
|
users: antenna.users,
|
|
instances: antenna.instances,
|
|
caseSensitive: antenna.caseSensitive,
|
|
notify: antenna.notify,
|
|
withReplies: antenna.withReplies,
|
|
withFile: antenna.withFile,
|
|
hasUnreadNote,
|
|
};
|
|
},
|
|
});
|