crated volume for attachments
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
|
||||
ARG NODE_VERSION=20.17.0
|
||||
|
||||
FROM node:${NODE_VERSION}-alpine
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Create the attachments directory and set permissions
|
||||
RUN mkdir -p attachments && chown -R node:node attachments
|
||||
|
||||
# Install dependencies
|
||||
RUN --mount=type=bind,source=package.json,target=package.json \
|
||||
--mount=type=bind,source=package-lock.json,target=package-lock.json \
|
||||
--mount=type=cache,target=/root/.npm \
|
||||
npm ci --omit=dev
|
||||
|
||||
# Switch to the node user
|
||||
USER node
|
||||
|
||||
COPY . .
|
||||
# Copy the application code
|
||||
COPY --chown=node:node . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD node server.js
|
||||
CMD node server.js
|
||||
@@ -529,7 +529,7 @@ async function insertContact(initiatorId, receiverId, contactUsername, read) {
|
||||
SELECT COUNT(DISTINCT user_id)
|
||||
FROM Memberships
|
||||
WHERE conversation_id = c.conversation_id
|
||||
) = 1 -- Allow a conversation with a single user (self)
|
||||
) = 1
|
||||
LIMIT 1
|
||||
`;
|
||||
const conversationResult = await client.query(findConversationQuery, [
|
||||
@@ -540,16 +540,20 @@ async function insertContact(initiatorId, receiverId, contactUsername, read) {
|
||||
|
||||
// Create new conversation if none exists
|
||||
if (!conversation_id) {
|
||||
console.error("CONVERSATION DON'T EXIST: ", conversation_id);
|
||||
const createConversationQuery = `
|
||||
INSERT INTO Conversations (conversation_type)
|
||||
VALUES ('direct')
|
||||
RETURNING conversation_id
|
||||
`;
|
||||
const newConversationResult = await client.query(createConversationQuery);
|
||||
|
||||
if (!newConversationResult) {
|
||||
console.error("Failed to create new conversation");
|
||||
return null;
|
||||
}
|
||||
|
||||
conversation_id = newConversationResult.rows[0].conversation_id;
|
||||
console.error("NEW CONVERSATION ID: ", conversation_id);
|
||||
// Create memberships for both users (or single user if they are the same)
|
||||
// Create memberships for users
|
||||
const createMembershipsQuery = `
|
||||
INSERT INTO Memberships (conversation_id, user_id)
|
||||
VALUES ($1, $2), ($1, $3)
|
||||
|
||||
Reference in New Issue
Block a user