-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chat): introduce auditMode, room deletions on leave and remove u…
…nique name requirement from rooms (#794) feat(chat): delete room when all participants have left fix(chat): room deletion not deleting associated messages refactor(chat): allow rooms with non-unique names feat(chat): introduce audit mode to keep chats and rooms after deletion feat(chat): add participant log to keep a history of who joins or leaves a room refactor(grpc-sdk): add missing types in query fix(chat): remove "any" from query fix(authorization): remove "any" from query chore: codefactor issues
- Loading branch information
1 parent
97fcb77
commit 1fc4484
Showing
13 changed files
with
222 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
modules/authorization/src/migrations/objectIndex.migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
modules/authorization/src/migrations/relationship.migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Query } from '@conduitplatform/grpc-sdk'; | ||
import { ChatMessage } from '../models'; | ||
|
||
export const migrateChatMessages = async () => { | ||
const query: Query<ChatMessage> = { | ||
$or: [{ deleted: '' }, { deleted: { $exists: false } }], | ||
}; | ||
let chatMessages = await ChatMessage.getInstance().findMany(query, undefined, 0, 100); | ||
while (chatMessages.length === 0) { | ||
for (const chatMessage of chatMessages) { | ||
await ChatMessage.getInstance().findByIdAndUpdate(chatMessage._id, { | ||
deleted: false, | ||
}); | ||
} | ||
chatMessages = await ChatMessage.getInstance().findMany(query, undefined, 0, 100); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Query } from '@conduitplatform/grpc-sdk'; | ||
import { ChatRoom } from '../models'; | ||
|
||
export const migrateChatRoom = async () => { | ||
const query: Query<ChatRoom> = { | ||
$or: [{ deleted: '' }, { deleted: { $exists: false } }], | ||
}; | ||
let chatRooms = await ChatRoom.getInstance().findMany(query, undefined, 0, 100); | ||
while (chatRooms.length === 0) { | ||
for (const chatRoom of chatRooms) { | ||
await ChatRoom.getInstance().findByIdAndUpdate(chatRoom._id, { | ||
deleted: false, | ||
participantsLog: [], | ||
}); | ||
} | ||
chatRooms = await ChatRoom.getInstance().findMany(query, undefined, 0, 100); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; | ||
import { migrateChatRoom } from './chatRoom.migrate'; | ||
import { migrateChatMessages } from './chatMessage.migrate'; | ||
|
||
export async function runMigrations(grpcSdk: ConduitGrpcSdk) { | ||
// ... | ||
await migrateChatRoom(); | ||
await migrateChatMessages(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.