all repos — stealth-developers @ 470d2c0df6a5bbd4e2128366d33bbe7b2ae69875

apps/bot/src/lib/tickets.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
import {
	type User,
	type Actor,
	type TicketWithRelations,
	type Guild,
} from "@stealth-developers/db";

export async function hasAccessToTicket(
	user: Actor | User,
	guild: Guild,
	ticket: TicketWithRelations,
) {
	if (user.discordId === ticket.subjectActor?.discordId) return true;
	if ("moderator" in user) if (user.guildId === guild.id && user.moderator) return true;
	return false;
}