Spaces:
Paused
Paused
adding the dashnoard rejected thigs
Browse files- src/routes/messages.js +4 -0
- src/routes/threads.js +7 -0
src/routes/messages.js
CHANGED
|
@@ -24,6 +24,10 @@ router.post('/', authMiddleware, async (req, res) => {
|
|
| 24 |
});
|
| 25 |
if (!thread) return res.status(404).json({ error: 'Thread not found' });
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
if (thread.giverWorkspaceId !== member.workspaceId && thread.receiverWorkspaceId !== member.workspaceId) {
|
| 28 |
return res.status(403).json({ error: 'Access denied' });
|
| 29 |
}
|
|
|
|
| 24 |
});
|
| 25 |
if (!thread) return res.status(404).json({ error: 'Thread not found' });
|
| 26 |
|
| 27 |
+
if (thread.status === 'REJECTED') {
|
| 28 |
+
return res.status(403).json({ error: 'This connection was rejected. You cannot send messages.' });
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
if (thread.giverWorkspaceId !== member.workspaceId && thread.receiverWorkspaceId !== member.workspaceId) {
|
| 32 |
return res.status(403).json({ error: 'Access denied' });
|
| 33 |
}
|
src/routes/threads.js
CHANGED
|
@@ -173,6 +173,13 @@ router.patch('/:id/status', authMiddleware, async (req, res) => {
|
|
| 173 |
receiverWorkspaceName: updated.receiverWorkspace.websiteName,
|
| 174 |
receiverWorkspaceDomain: updated.receiverWorkspace.domain,
|
| 175 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
}
|
| 177 |
|
| 178 |
res.json({ thread: updated });
|
|
|
|
| 173 |
receiverWorkspaceName: updated.receiverWorkspace.websiteName,
|
| 174 |
receiverWorkspaceDomain: updated.receiverWorkspace.domain,
|
| 175 |
});
|
| 176 |
+
} else if (status === 'REJECTED') {
|
| 177 |
+
wsManager.sendNotification(updated.giverWorkspaceId, {
|
| 178 |
+
type: 'connection_rejected',
|
| 179 |
+
threadId: updated.id,
|
| 180 |
+
receiverWorkspaceName: updated.receiverWorkspace.websiteName,
|
| 181 |
+
receiverWorkspaceDomain: updated.receiverWorkspace.domain,
|
| 182 |
+
});
|
| 183 |
}
|
| 184 |
|
| 185 |
res.json({ thread: updated });
|