fixes
All checks were successful
Build And Push Image / docker (push) Successful in 3m41s

This commit is contained in:
2025-08-13 15:35:53 +02:00
parent 62fb84d25e
commit db19eb2708
4 changed files with 95 additions and 34 deletions

View File

@@ -34,6 +34,14 @@ export default defineEventHandler(async (event) => {
console.log('[api/events.get] ✅ Valid session found for user:', session.user.email);
console.log('[api/events.get] User tier:', session.user.tier);
// Get member record to find the member_id needed for RSVP lookup
const { getMemberByKeycloakId } = await import('~/server/utils/nocodb');
const member = await getMemberByKeycloakId(session.user.id);
const memberIdentifier = member?.member_id || member?.Id || session.user.id;
console.log('[api/events.get] Using member identifier for RSVP lookup:', memberIdentifier);
console.log('[api/events.get] Member details:', { member_id: member?.member_id, database_id: member?.Id });
const eventsClient = createNocoDBEventsClient();
// Build filters with user role
@@ -56,8 +64,8 @@ export default defineEventHandler(async (event) => {
console.log('[api/events.get] Fetching events with filters:', filters);
// Get events from database
const response = await eventsClient.findUserEvents(session.user.id, filters);
// Get events from database using the member identifier (not Keycloak ID)
const response = await eventsClient.findUserEvents(memberIdentifier, filters);
console.log('[api/events.get] ✅ Successfully fetched', response.list.length, 'events');

View File

@@ -412,28 +412,61 @@ export function createNocoDBEventsClient() {
},
/**
* Get events for a specific user (simplified version)
* Get events for a specific user with RSVP status loaded
*/
async findUserEvents(memberId: string, filters?: EventFilters) {
console.log('[nocodb-events] Finding events for member:', memberId);
try {
// For now, just get all visible events using the working findAll method
// Remove complex filtering temporarily to fix the 422 errors
// First get all events using the working findAll method
const simpleFilters = {
status: filters?.status,
limit: (filters as any)?.limit,
offset: (filters as any)?.offset
};
console.log('[nocodb-events] Using simplified filters to avoid 422 errors:', simpleFilters);
const events = await this.findAll(simpleFilters);
console.log('[nocodb-events] Using simplified filters:', simpleFilters);
const eventsResponse = await this.findAll(simpleFilters);
if (!eventsResponse.list || eventsResponse.list.length === 0) {
console.log('[nocodb-events] No events found');
return eventsResponse;
}
console.log('[nocodb-events] Found', eventsResponse.list.length, 'events, now loading RSVPs for member:', memberId);
// Load RSVPs for each event for this user
const eventsWithRSVPs = await Promise.all(
eventsResponse.list.map(async (event) => {
try {
// Use event_id if available, otherwise fall back to database Id
const eventIdentifier = event.event_id || event.id || (event as any).Id;
console.log('[nocodb-events] Loading RSVP for event:', event.title, 'identifier:', eventIdentifier);
const userRSVP = await this.findUserRSVP(eventIdentifier, memberId);
if (userRSVP) {
console.log('[nocodb-events] ✅ Found RSVP for event', event.title, ':', userRSVP.rsvp_status);
return {
...event,
user_rsvp: userRSVP
};
} else {
console.log('[nocodb-events] No RSVP found for event:', event.title);
return event;
}
} catch (rsvpError) {
console.log('[nocodb-events] ⚠️ Error loading RSVP for event', event.title, ':', rsvpError);
return event; // Return event without RSVP if lookup fails
}
})
);
console.log('[nocodb-events] ✅ Loaded RSVPs for all events');
// TODO: Add RSVP lookup from separate table
// For now, return events without RSVP status
return {
list: events.list || [],
PageInfo: events.PageInfo
list: eventsWithRSVPs,
PageInfo: eventsResponse.PageInfo
};
} catch (error: any) {
console.error('[nocodb-events] Error finding user events:', error);