Foro: mover tema entre foros (moderadores)
- lib/forum-write.ts: moveTopic (forum_id + moved=1). lib/forum.ts: listForumsForMove. - API /api/forum/moderate: acción 'move' con forumId, validando foro destino visible y distinto del actual. - TopicModBar: selector «Mover a» con los foros visibles (excl. el actual); tras mover, redirige al foro destino. - i18n es/en: Forum.moveTopic. Verificado: build OK, move 401 sin sesión, /forum 200. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,11 @@ export async function setTopicFlag(
|
||||
await db(DB.web).query(`UPDATE forum_topics SET ${field} = ? WHERE id = ?`, [value ? 1 : 0, topicId])
|
||||
}
|
||||
|
||||
/** Mueve un tema a otro foro (marca moved=1). Solo moderación. */
|
||||
export async function moveTopic(topicId: number, newForumId: number): Promise<void> {
|
||||
await db(DB.web).query('UPDATE forum_topics SET forum_id = ?, moved = 1 WHERE id = ?', [newForumId, topicId])
|
||||
}
|
||||
|
||||
/** Comprueba que un foro existe y es visible (para crear tema). */
|
||||
export async function forumIsPostable(forumId: number): Promise<boolean> {
|
||||
const [rows] = await db(DB.web).query<RowDataPacket[]>(
|
||||
|
||||
@@ -92,6 +92,18 @@ export async function getForumIndex(): Promise<Category[]> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Lista de foros visibles para el desplegable de «mover tema». */
|
||||
export async function listForumsForMove(): Promise<{ id: number; name: string }[]> {
|
||||
try {
|
||||
const [rows] = await db(DB.web).query<RowDataPacket[]>(
|
||||
'SELECT id, name FROM forums WHERE visibility = 1 AND deleted = 0 ORDER BY `order`, id',
|
||||
)
|
||||
return rows.map((r) => ({ id: r.id, name: r.name }))
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
export async function getForum(id: number): Promise<{ name: string; description: string } | null> {
|
||||
try {
|
||||
const [rows] = await db(DB.web).query<RowDataPacket[]>(
|
||||
|
||||
Reference in New Issue
Block a user