|
@@ -14,8 +14,12 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
|
|
|
|
/* Set up the targets or points of synchronization. This is where it will register the 2 different location of
|
|
|
the data to be synchronized */
|
|
|
- public init(settings: MessageSynchronisationServiceSetting): void {
|
|
|
+ public init(settings: MessageSynchronisationServiceSetting, filters?: any): void {
|
|
|
this.settings = settings;
|
|
|
+ if (filters) {
|
|
|
+ console.log(`Integrating filters: ${Object.keys(this.filter)} in AuditMessage service`)
|
|
|
+ this.filter = filters
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/* This is the main interface of the message sync service. The argument will take in an observable stream of
|
|
@@ -45,11 +49,6 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
|
return this.missingMessageSubject
|
|
|
}
|
|
|
|
|
|
- public setFilter(filters: any) {
|
|
|
- this.filter = filters
|
|
|
- console.log(`Integrating filters: ${Object.keys(this.filter)} in AuditMessage service`)
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/* ________________ Private Functions _________________ */
|
|
|
// Filtering functions to filter out messages
|
|
@@ -59,12 +58,22 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
|
// Making a separate function to cater to different multi filter conditions are coded below
|
|
|
function checkValues(filter): boolean { //FYI, all parameters are string
|
|
|
let key = Object.keys(filter)
|
|
|
- let value = Object.values(filter)
|
|
|
+ console.log(Object.values(filter))
|
|
|
+ let value = Object.values(filter)[0]
|
|
|
let res = _.get(payload, key[0])
|
|
|
// Check first if the payload has the filtering properties/path
|
|
|
if (_.has(payload, key[0])) {
|
|
|
// check if value is equal to fitler's
|
|
|
- if (value == res) {
|
|
|
+ let strarray: string[]
|
|
|
+ // check array
|
|
|
+ if (Array.isArray(value)) {
|
|
|
+ strarray = value as string[]
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strarray = [value as string]
|
|
|
+ }
|
|
|
+ // compare array with that string
|
|
|
+ if (strarray.includes(res)) {
|
|
|
return true
|
|
|
} else {
|
|
|
return false
|