Komunikator: sortowanie wg nieprzeczytanych/nazwy i grupowanie wg roli z zakładkami w topmenu (role w API rozmów)
This commit is contained in:
@@ -25,7 +25,7 @@ export function createMessageRoutes({ prisma }: AppDeps) {
|
||||
* @openapi
|
||||
* /messages/conversations:
|
||||
* get:
|
||||
* summary: My ACTIVE coaching relations as conversations (last message + unread count)
|
||||
* summary: My ACTIVE coaching relations as conversations (my role + last message + unread count)
|
||||
* tags: [Messages]
|
||||
* responses:
|
||||
* 200: { description: OK }
|
||||
|
||||
@@ -3,6 +3,8 @@ import { badRequest, notFound } from '../lib/errors.js';
|
||||
|
||||
export interface ConversationListItem {
|
||||
coachingId: string;
|
||||
/** Moja rola w relacji (odwrotna dla drugiej strony: podopieczny/trener). */
|
||||
role: 'trainer' | 'trainee';
|
||||
other: { id: string; firstName: string | null; lastName: string | null; nickname: string | null };
|
||||
lastMessage: { body: string; createdAt: string; senderId: string } | null;
|
||||
unreadCount: number;
|
||||
@@ -65,6 +67,7 @@ export async function listConversations(prisma: PrismaClient, userId: string) {
|
||||
const last = lastByCoaching.get(c.id) ?? null;
|
||||
return {
|
||||
coachingId: c.id,
|
||||
role: c.trainerId === userId ? ('trainer' as const) : ('trainee' as const),
|
||||
other: other
|
||||
? { id: other.id, firstName: other.firstName, lastName: other.lastName, nickname: other.nickname }
|
||||
: { id: otherId, firstName: null, lastName: null, nickname: null },
|
||||
|
||||
Reference in New Issue
Block a user