Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: npm test

deploy:
needs: test #if tests fail will not deploy
#needs: test #if tests fail will not deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
72 changes: 37 additions & 35 deletions backend/src/controllers/group.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
sendGroupLeaveFCM,
sendActivitySelectedFCM,
} from '../services/fcm.service';
import { getWebSocketService } from '../services/websocket.service';

export class GroupController {
async createGroup(
Expand Down Expand Up @@ -194,7 +195,7 @@ export class GroupController {
}

// Send WebSocket notifications for new members
/*const wsService = getWebSocketService();
const wsService = getWebSocketService();
if (wsService) {
const currentMemberIds = (currentGroup.groupMemberIds || []).map(member => member.id);
const newMemberIds = (groupMemberIds || []).map(member => member.id);
Expand All @@ -215,7 +216,7 @@ export class GroupController {
// FCM topic notification (clients subscribe to topic == joinCode)
void sendGroupJoinFCM(joinCode, member.name, updatedGroup.groupName, member.id);
});
}*/
}

res.status(200).json({
message: 'Group info updated successfully',
Expand Down Expand Up @@ -622,37 +623,37 @@ export class GroupController {
const updatedTravelTime = await groupModel.updateMemberTravelTime(updatedGroup, locationService, true);

// Send notifications to group members
//const wsService = getWebSocketService();
// if (wsService && updatedGroup) {
// const leaderId = updatedGroup.groupLeaderId.id || '';
// const leaderName = updatedGroup.groupLeaderId.name || 'Group leader';
// const rawActivityName = activity.name;
// const activityName: string = typeof rawActivityName === 'string' ? rawActivityName : 'an activity';

// // Send WebSocket notification
// wsService.notifyGroupUpdate(
// joinCode,
// `${leaderName} selected "${activityName}" for the group`,
// {
// type: 'activity_selected',
// activity,
// leaderId,
// leaderName
// }
// );

// // Send FCM notification (will be suppressed in foreground on client side)
// const activityDataStr = JSON.stringify(activity);
// sendActivitySelectedFCM(
// joinCode,
// activityName,
// updatedGroup.groupName,
// leaderId,
// activityDataStr
// ).catch((error: unknown) => {
// logger.error('Failed to send activity selected FCM notification:', error);
// });
// }
const wsService = getWebSocketService();
if (wsService && updatedGroup) {
const leaderId = updatedGroup.groupLeaderId.id || '';
const leaderName = updatedGroup.groupLeaderId.name || 'Group leader';
const rawActivityName = activity.name;
const activityName: string = typeof rawActivityName === 'string' ? rawActivityName : 'an activity';

// Send WebSocket notification
wsService.notifyGroupUpdate(
joinCode,
`${leaderName} selected "${activityName}" for the group`,
{
type: 'activity_selected',
activity,
leaderId,
leaderName
}
);

// Send FCM notification (will be suppressed in foreground on client side)
const activityDataStr = JSON.stringify(activity);
sendActivitySelectedFCM(
joinCode,
activityName,
updatedGroup.groupName,
leaderId,
activityDataStr
).catch((error: unknown) => {
logger.error('Failed to send activity selected FCM notification:', error);
});
}

// Send notifications to group members
/*const wsService = getWebSocketService();
Expand Down Expand Up @@ -772,7 +773,7 @@ export class GroupController {
const result = await groupModel.leaveGroup(joinCode, userId);

// Send WebSocket notification for user leaving
/*const wsService = getWebSocketService();
const wsService = getWebSocketService();
if (wsService && leavingUser) {
wsService.notifyGroupLeave(
joinCode,
Expand Down Expand Up @@ -805,7 +806,8 @@ export class GroupController {
`${result.newLeader.name} is now the new group leader`,
{ newLeader: result.newLeader }
);
}*/
}
}

res.status(200).json({
message: 'Left group successfully',
Expand Down
Loading