Skip to content

Commit

Permalink
Release 0.29.0 (#159)
Browse files Browse the repository at this point in the history
* SK-217 Implemented group chat images  (#117)

* SK-189 added `avatar_object` field for user object

* SK-189 implemented the logic of creating links for downloading user avatars

* SK-189 renamed downloadFile to getFileDownloadUrl

* SK-217 added `image_object` for Conversation fields

* SK-217 added `image_url` field to the system event

* SK-217 added sending update request to other users

* SK-217 cleanup

* SK-217 minor fix

* SK-217 added image_object for conversationCreate

* SK-217 add log

* SK-217 remove log

* SK-217 add log

* SK-217 remove log

* SK-194 updated `typing` object (#121)

* Sk-194 updated typing object

* SK-194 updated API.md

* SK-234 removed file name from uuid in file `object_id` (#122)

* updated CHANGELOG.md (0.24.0 -> 0.25.0)

* Updated tests for status typing (removed tests for deleted fields)

* FM-27 added device_token for push subscription (#136)

* Release 0.25.0 (#123)

* SK-217 Implemented group chat images  (#117)

* SK-189 added `avatar_object` field for user object

* SK-189 implemented the logic of creating links for downloading user avatars

* SK-189 renamed downloadFile to getFileDownloadUrl

* SK-217 added `image_object` for Conversation fields

* SK-217 added `image_url` field to the system event

* SK-217 added sending update request to other users

* SK-217 cleanup

* SK-217 minor fix

* SK-217 added image_object for conversationCreate

* SK-217 add log

* SK-217 remove log

* SK-217 add log

* SK-217 remove log

* SK-194 updated `typing` object (#121)

* Sk-194 updated typing object

* SK-194 updated API.md

* SK-234 removed file name from uuid in file `object_id` (#122)

* updated CHANGELOG.md (0.24.0 -> 0.25.0)

* Release 0.25.0 (#124)

* SK-217 Implemented group chat images  (#117)

* SK-189 added `avatar_object` field for user object

* SK-189 implemented the logic of creating links for downloading user avatars

* SK-189 renamed downloadFile to getFileDownloadUrl

* SK-217 added `image_object` for Conversation fields

* SK-217 added `image_url` field to the system event

* SK-217 added sending update request to other users

* SK-217 cleanup

* SK-217 minor fix

* SK-217 added image_object for conversationCreate

* SK-217 add log

* SK-217 remove log

* SK-217 add log

* SK-217 remove log

* SK-194 updated `typing` object (#121)

* Sk-194 updated typing object

* SK-194 updated API.md

* SK-234 removed file name from uuid in file `object_id` (#122)

* updated CHANGELOG.md (0.24.0 -> 0.25.0)

* Updated tests for status typing (removed tests for deleted fields)

* Update API.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* updated package.json

* Update README.md

* Сhange development flow (#132)

* FM-27 added `device_token` for push subscription

* FM-27 minor cleanup

* FM-27 removed `rsmq-promise`, updated bull queue  methods

* FM-27 renamed minor comments

---------

Co-authored-by: IgorKhomenko <[email protected]>
Co-authored-by: Igor Khomenko <[email protected]>
Co-authored-by: ku9nov <[email protected]>

* updated CHANGELOG.md

* renamed env file

* updated tests for `push_subcriptions`, added indexes for the `push_subcriptions` collection

* SK-273 remove `platform` field from pushEvent object (#141)

* SK-272 extended `conversation_list` request to allow request convs by ids (#142)

* SK-272 added `ids` options for conversation_list, added test, updated API.md

* SK-272 added limit for ids field - 10

* SK-272 updated API.md

* Updated CHANGELOG.md

* Fixes different naming of methods

* Updated CHANGELOG.md

* Added `cid` field for push notification object

* SK-278  implemented support for `refresh_token`, added `connect_socket` request (#147)

* SK-278 added `connect_socket` request, implemented support for `refresh_token`

* SK-278 updated API.md

* SK-278 init HttpAuthController

* SK-278 minor fix

* SK-278 deprecated user_logout

* SK-278 added log

* SK-278 tmpToken -> refresh_token

* SK-278 added cookie signature

* SK-278 minor fix

* SK-278 removed log

* SK-278 remove token from cookie if it`ss incorrect

* SK-278  added function of reading header

* SK-278 removed error validation from  getAccessTokenFromHeader

* SK-278 added logs

* SK-278 removed logs

* SK-278 updated API.md

* SK-278 fixed expired_at field in auth response

* SK-278 fixed access and refresh jwt expiresIn

* SK-278 added refresh_token to all variants of response for auth

* SK-278 create new refresh token every time

* SK-278 added log

* SK-278 replaced cors settings

* SK-278 added onAborted handler for http requests

* Updated `user_search` query param, changed status for `unauthorized` error (#146)

* Updated user_search param name & updated error status for `Unauthorized`

* added logs

* removed logs

* Added a load testing scheme (#149)

* added load test

* updated test plan

* updated README.md

* added new envs

* updated pm2.config.cjs

* added testing results

* updated RESULTS.md

* updated RESULTS.md

* updated CHANGELOG.md

* revert pm2.config.cjs

* undo revert pm2.config.cjs

* fix tests

* SK-291 allowed param `lt` for `conversation_list` request (#154)

* Updated node to v22.14, mongo to v6.0 (#155)

* updated node version to 22.14

* updated ObjectId compability

* fixed findOneAndUpdate response to mongo 6, tests

* SK-297 added `conversation` field to `get_participants_by_cids` request (#157)

* Disabled notifications when creating private conversations (#156)

* updated .env.frontend for docker

* added returning an empty refersh token onerror

* Refactor frontend deployment: Build in container & serve via Nginx (#158)

* change client build

* change client build for default compose file

* add nginx to overrides

* updated CHANGELOG.md

* fixed tests

---------

Co-authored-by: IgorKhomenko <[email protected]>
Co-authored-by: Igor Khomenko <[email protected]>
Co-authored-by: ku9nov <[email protected]>
Co-authored-by: ku9nov <[email protected]>
  • Loading branch information
5 people authored Mar 4, 2025
1 parent 795b4af commit c0f6254
Show file tree
Hide file tree
Showing 32 changed files with 369 additions and 213 deletions.
5 changes: 4 additions & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ SSL_KEY_FILE_NAME=
SSL_CERT_FILE_NAME=

# set this env if you want to override the os.hostname() value
HOSTNAME=NodeName
HOSTNAME=NodeName
CORS_ORIGIN=http://localhost:10000
COOKIE_SECRET=4c09be6a35bec6d4089cde4be5ca57a6ee85da5739579cbecb0b8253f268eca2

9 changes: 4 additions & 5 deletions APIs/JSON/controllers/conversations.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ class ConversationsController extends BaseJSONController {
const conversationCreateOperation = ServiceLocatorContainer.use("ConversationCreateOperation")
const { conversation, event } = await conversationCreateOperation.perform(ws, conversationParams)

const deliverMessage = new DeliverMessage(event.participantIds, event.message).addPushQueueMessage(
event.notification
)
const deliverMessage = new DeliverMessage(event.participantIds, event.message)
conversation.type !== "u" && deliverMessage.addPushQueueMessage(event.notification)

return new Response()
.addBackMessage({
Expand Down Expand Up @@ -120,10 +119,10 @@ class ConversationsController extends BaseJSONController {
const { id: requestId, get_participants_by_cids: options } = data

const conversationListParticipantsOperation = ServiceLocatorContainer.use("ConversationListParticipantsOperation")
const users = await conversationListParticipantsOperation.perform(ws, options)
const { users, conversations } = await conversationListParticipantsOperation.perform(ws, options)

return new Response().addBackMessage({
response: { id: requestId, users: users },
response: { id: requestId, users, conversations },
})
}

Expand Down
2 changes: 1 addition & 1 deletion APIs/JSON/controllers/http/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HttpAuthController extends BaseHttpController {
if (unsignedToken !== false) {
return unsignedToken
} else {
// this.#setRefreshTokenCookie(res, signedToken, true)
this.setRefreshToken(res, signedToken, true) //uncommented changes
throw new Error(ERROR_STATUES.INCORRECT_TOKEN.message, {
cause: {
status: ERROR_STATUES.INCORRECT_TOKEN.status,
Expand Down
1 change: 1 addition & 0 deletions APIs/JSON/validations/conversations_schema_validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const conversationsSchemaValidation = {
limit: Joi.number(),
updated_at: Joi.object({
gt: Joi.date(),
lt: Joi.date(),
}),
ids: Joi.array().items(Joi.alternatives().try(Joi.object(), Joi.string())).max(10),
}).required(),
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 0.29.0

### Updated

- Migrated server to Node v22.14
- Updated mongoDB to v6.0
- Removed notification when creating a 1-1 chat

### Improvements

- Added suport for `lt` for `conversation_list` request
- Added `conversation` field to the response to the `get_participants_by_cids` request

### Docker

- Improved logic for building the Docker container

## 0.28.0

### Feature
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.16.0 as builder
FROM node:22.14.0 as builder

WORKDIR /app

Expand All @@ -8,7 +8,7 @@ RUN npm install

COPY . .

FROM node:18-slim
FROM node:22-slim

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.16.0 as builder
FROM node:22.14.0 as builder

WORKDIR /app

Expand All @@ -8,7 +8,7 @@ RUN npm install

COPY . .

FROM node:18-slim
FROM node:22-slim

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ If you are encountering issues with attachments in the web client, it suggests t
Now you can access apps at the following addresses:

- [Server-API](http://localhost:9000)
- [Web-Client](http://localhost:3000)
- [Web-Client](http://localhost:10000)
- [Minio-API](http://localhost:9010)
- [Minio-Client](http://localhost:9011)
- [Push-dashboard](http://localhost:3001/ui)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ class ConversationListParticipantsOperation {
const currentUserId = this.sessionService.getSessionUserId(ws)
const currentUser = await this.userService.userRepo.findById(currentUserId)

const participantIds = await this.conversationService.findConversationsParticipantIds(cids, currentUser)
const { participantIds, participantsIdsByCids } = await this.conversationService.findConversationsParticipantIds(
cids,
currentUser
)

if (!participantIds.length) {
return []
return { users: [], conversations: {} }
}

const users = await this.userService.userRepo.findAllByIds(participantIds)
Expand All @@ -23,7 +26,7 @@ class ConversationListParticipantsOperation {

const userFields = usersWithAvatars.map((user) => user.visibleParams())

return userFields
return { users: userFields, conversations: participantsIdsByCids }
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/providers/repositories/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default class BaseRepository {
.findOneAndUpdate(query, update, { returnDocument: "after" })
.catch((error) => error)

const model = record.ok && record.value ? this.wrapRawRecordInModel(record.value) : null
const model = record ? this.wrapRawRecordInModel(record) : null

return model
}
Expand Down
7 changes: 5 additions & 2 deletions app/providers/repositories/conversation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ class ConversationRepository extends BaseRepository {
_id: { $in: conversationIds },
}

if (options.updatedAtFrom) {
query.updated_at = this.mergeOperators(query.updated_at, { $gt: options.updatedAtFrom })
if (options.updatedAtFrom || options.updatedAtTo) {
query.updated_at = this.mergeOperators(query.updated_at, {
...(options.updatedAtFrom && { $gt: options.updatedAtFrom }),
...(options.updatedAtTo && { $lt: options.updatedAtTo }),
})
}

const conversations = await this.findAll(query, null, limit)
Expand Down
21 changes: 18 additions & 3 deletions app/providers/repositories/conversation_participants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,24 @@ class ConversationParticipantRepository extends BaseRepository {
})
const availableConversationIds = availableConversationParticipants.map((participant) => participant.conversation_id)

const conversationsParticipants = await this.findAll({ conversation_id: { $in: availableConversationIds } })

return conversationsParticipants
const conversationsParticipants = await this.aggregate([
{ $match: { conversation_id: { $in: availableConversationIds } } },
{ $group: { _id: "$conversation_id", users: { $push: "$user_id" } } },
{
$project: {
_id: 0,
conversation_id: { $toString: "$_id" },
users: { $map: { input: "$users", as: "u", in: { $toString: "$$u" } } },
},
},
])

const conversationsParticipantsByIds = conversationsParticipants.reduce((arr, { conversation_id, users }) => {
arr[conversation_id] = users
return arr
}, {})

return conversationsParticipantsByIds
}

async findUserConversationIds(conversationIds, user_id) {
Expand Down
2 changes: 1 addition & 1 deletion app/providers/repositories/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class UserRepository extends BaseRepository {
async update(userId, updateParams) {
const user = await this.findOneAndUpdate({ _id: userId }, { $set: updateParams })

return user
return user.errorResponse ? null : user
}

async updateActivity(userId, recentActivity) {
Expand Down
10 changes: 6 additions & 4 deletions app/providers/services/conversation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class ConversationService {
? this.validateConvIdsWhichUserHasAccess(options.ids, user.native_id)
: this.conversationParticipantRepo.findParticipantConversations(user.native_id, limit))

const filterOptions = {}
if (options.updatedAt?.gt) {
filterOptions.updatedAtFrom = new Date(options.updatedAt.gt)
const filterOptions = {
...(options.updatedAt?.gt && { updatedAtFrom: new Date(options.updatedAt.gt) }),
...(options.updatedAt?.lt && { updatedAtTo: new Date(options.updatedAt.lt) }),
}

const conversations = await this.conversationRepo.list(conversationIds, filterOptions, limit)
Expand Down Expand Up @@ -81,7 +81,9 @@ class ConversationService {
user.native_id
)

return conversationsParticipants.map((participant) => participant.user_id)
const participantIds = [...new Set(Object.values(conversationsParticipants).flat())]

return { participantIds, participantsIdsByCids: conversationsParticipants }
}

async validateConvIdsWhichUserHasAccess(conversationIds, userId) {
Expand Down
2 changes: 1 addition & 1 deletion app/utils/crypto_utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import crypto from "crypto"
import crypto from "node:crypto"

const STRETCHES = 20

Expand Down
20 changes: 16 additions & 4 deletions docker-compose-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ networks:

services:
nginx:
depends_on:
- sama-client
- sama-server
networks:
sama_network:
ipv4_address: 172.25.0.8
Expand All @@ -19,18 +22,26 @@ services:
dockerfile: Dockerfile.nginx
ports:
- "9000:9000"
- "10000:10000"
volumes:
- sama-client-dist:/usr/share/nginx/html:ro

sama-client:
build:
context: ./prefs/client
dockerfile: Dockerfile.frontend
args:
VITE_SOCKET_CONNECT: ws://localhost:9000
VITE_HTTP_CONNECT: http://localhost:9000
VITE_PUBLIC_VAPID_KEY: BNeoP95lfdpIEMTBay5bkjn3VgQHR0fg5feo375mQ7h8kpVh_43HXtISrQnzZwrja83cjCGlBA9FtIOzHeqy4dE
VITE_MESSAGES_COUNT_TO_PRELOAD: 30
BRANCH: development
networks:
sama_network:
ipv4_address: 172.25.0.9
ports:
- "3000:3000"
volumes:
- ./prefs/client/.env.frontend:/app/.env
- sama-client-dist:/dist
command: [ "echo", "Static files are ready" ]

sama-server:
build:
Expand Down Expand Up @@ -165,4 +176,5 @@ services:

volumes:
data:
mongo:
mongo:
sama-client-dist:
7 changes: 7 additions & 0 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ services:
deploy:
replicas: 0

nginx:
# Define the service here as an empty object to effectively exclude it
# Or simply leave it out if you want to remove it completely
# Example:
deploy:
replicas: 0

sama-server:
# Define the service here as an empty object to effectively exclude it
# Or simply leave it out if you want to remove it completely
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ services:
file: ./prefs/docker-compose/services/frontend.yml
service: sama-client

nginx:
extends:
file: ./prefs/docker-compose/services/frontend.yml
service: nginx

sama-server:
extends:
file: ./prefs/docker-compose/services/backend.yml
Expand Down Expand Up @@ -51,4 +56,5 @@ services:

volumes:
data:
mongo:
mongo:
sama-client-dist:
10 changes: 8 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,14 @@ When a user leaves the group chat, the next message will also be sent to all use
{
_id: "63480e68f4794709f802a2fa",
login: "breadpit"
}
]
},
...
],
conversations: {
635a3b4cb15254ebe43e76ff: [634ec51c0b65918393dca5bf, 63480e68f4794709f802a2fa],
63563a2ad745dc1c6ad01b5f: [63480e68f4794709f802a2fa, 507f191e810c19729de860ea, 507f191e810c19729de880ee],
...
}
}
}
```
Expand Down
2 changes: 0 additions & 2 deletions migrate-mongo-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ const config = {
url: process.env.MONGODB_URL,

options: {
useNewUrlParser: true, // removes a deprecation warning when connecting
useUnifiedTopology: true, // removes a deprecating warning when connecting
// connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
// socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
},
Expand Down
Loading

0 comments on commit c0f6254

Please sign in to comment.