-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: a proposal to fix the admin user message flow #32
fix: a proposal to fix the admin user message flow #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎖️ good work!
lib/PersistHelper.ts
Outdated
const persistenceRead: IPersistenceRead = read.getPersistenceReader(); | ||
const results = await persistenceRead.readByAssociations(associations) as Array<UserRegistrationModel>; | ||
|
||
if (results === undefined || results === null || results.length == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (results === undefined || results === null || results.length == 0) { | |
if (results == null || results.length == 0) { |
undefined == null is true
@@ -1001,3 +1019,181 @@ export const retrieveLoginMessageSentStatus = async ({ | |||
|
|||
return result[0].isLoginMessageSent; | |||
}; | |||
|
|||
type LastBridgedMessageInfo = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a 1000+ lines file please avoid defining types here, its better to import them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider only my last comment - the try/catch block - in this request changes. Every other feedback is to enhance the quality of the source code, but its ok to go forward if you feel the need of speed.
return result[0]; | ||
}; | ||
|
||
const simpleHash = (input: string): string => sha256(input).toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be in another file
rocketChatUserId, | ||
messageFootprint, | ||
// source | ||
}: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please avoid adding types later as it increases the number of lines and complexity of the file.
lib/PersistHelper.ts
Outdated
messageFootprint: string | ||
persistence: IPersistence, | ||
rocketChatUserId: string; | ||
// source: 'rocket.chat' | 'msteams' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid commenting unused code
), | ||
]; | ||
|
||
return (await read.getPersistenceReader().readByAssociations(associations)).shift() as MessageFootprintInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a promise, avoid return await expressions.
This PR addresses the messaging flow issue that occurs when the user who created the bridge sends a message to both Teams and Rocket.Chat. The following changes have been made to resolve the problem:
Modified the logic that prevented messages from admins being set as senders. Now, admin messages can be properly processed as senders.
Introduced a footprint mechanism to determine whether a message has already been sent based on its text, user, room, and file name. This ensures that duplicate messages are avoided.
Implemented a persistence feature to store information about sent messages. Before sending a message, the system checks the persistence records to prevent messaging loops between Rocket.Chat and Teams.