Service - Notification Manager: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 42: Line 42:
{
{
type: "versionedData",
type: "versionedData",
versionedDataLabel: "notificationGroupSetting",
versionedDataLabel: "notificationGroupSettings",
storageResourceTag: "myGraph",
storageResourceTag: "myGraph",
fieldNames: [
fieldNames: [
{ // fieldName in versionedData should now same in main objectSchema
{ // fieldName in versionedData should now same in main objectSchema
fieldName: "notificationGroupName"
fieldName: "notificationGroupName",
type: "string",
requiredOnCreate: true, // default = false
optionalOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {
pattern: pattern
}
},
},
{  
{  
fieldName: "consolidated",
fieldName: "consolidated",
type: "boolean",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
},
},
{
{
fieldName: "consolidatedType"
fieldName: "consolidatedType",
type: "string",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
},
},
{
{
fieldName: "consolidatedFrequency"
fieldName: "consolidatedFrequency",
type: "string",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
},
},
{
{
fieldName: "consolidatedSendIfEmpty"
fieldName: "consolidatedSendIfEmpty",
type: "boolean",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: true,
validation: {
pattern: pattern
}
}
}
]
]
Line 71: Line 106:
     },
     },
     fieldNames: { // see Per Service Schemas
     fieldNames: { // see Per Service Schemas
notificationGroupId: {},
notificationGroupId: {
additionalData: {},
    type: "string",
        recieverTag: {}
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
},
receiverTag: {
type: "string",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
},
additionalData: {
type: "object",
optionalOnCreate: true,
requiredOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
}
     },
     },
     identifiers: [
     identifiers: [
Line 120: Line 181:
{
{
type: "versionedData",
type: "versionedData",
versionedDataLabel: "notificationSetting",
versionedDataLabel: "notificationSettings",
storageResourceTag: "myGraph",
storageResourceTag: "myGraph",
fieldNames: [
fieldNames: [
{ // fieldName in versionedData should now same in main objectSchema
{ // fieldName in versionedData should now same in main objectSchema
fieldName: "notificationName"
fieldName: "notificationName",
type: "string",
requiredOnCreate: true, // default = false
optionalOnCreate: true, // default = false
canUpdate: true, // default = true
validation: {
pattern: pattern
}
}
}
]
]
Line 137: Line 205:
     },
     },
     fieldNames: {
     fieldNames: {
notificationId: {},
notificationId: {
    type: "string",
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
},
     },
     },
     identifiers: [
     identifiers: [
Line 171: Line 247:
     },
     },
     fieldNames: {
     fieldNames: {
notificationTriggerId: {},
notificationTriggerId: {
propertyName: {},
type: "string",
valueType: {},
optionalOnCreate: true,
value: {},
canUpdate: false,
values: {}
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
}
},
propertyName: {
type: "string",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
},
valueType: {
type: "string",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
},
value: {
type: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // can be "string" or "number"
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
},
values: {
type: "arrayMixed",
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['myGraph']
}
     },
     },
     identifiers: [
     identifiers: [
Line 196: Line 315:
: property|attribute|serviceName|topicName
: property|attribute|serviceName|topicName
; value
; value
: {string or number}
: '''type: string or number'''
; values
; values
: {array/list of value}
: '''type: array/list of value (arrayMixed??)'''




Line 206: Line 325:
{
{
objectType: "consolidated",
objectType: "consolidated",
canDelete: true,
canDelete: false,
     complexFilterServiceTag: "complexFilter",
     complexFilterServiceTag: "complexFilter",
     storageResources: {
     storageResources: {
Line 215: Line 334:
     },
     },
     fieldNames: {
     fieldNames: {
notificationGroupId: {},
notificationGroupId: {
time: {},
type: "string",
activityMsg: {}
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['dynamoDB']
},
time: {
type: "number",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['dynamoDB']
},
activityMsg: {
type: "object",
requiredOnCreate: true,
optionalOnCreate: true,
canUpdate: false,
validation: {
pattern: pattern
},
storageResourceTags: ['dynamoDB']
}
     },
     },
     identifiers: [
     identifiers: [

Revision as of 08:58, 5 July 2024

Overview

Consolidates and sends notifications to any number of receiver services. Will be used for user notifications but can have other types of receiver services added. Activities are received from Activity Switchboard service.

Notification groups set whether activities are considated (eg per day/per month/per x number of activities), if considated activities are stored here until sending is triggered, according to the considation rules. If not consolidated they are sent on immediately.

Repository

https://bitbucket.org/stb_working/notification-manager/src/master/

DynamoDB tables

PendingConsolidation Table

partition key
  • notificationGroupId
type: string
comes from: random UUID
sort key
  • time
type: number
{timestamp activity handled in Activity Switchboard}_{small random UUID}

Object Schemas

Additional Information
Per Service Schemas

objType

notificationGroup

  • Groups many notificatons together
  • Simplifies management of similar notifications
  • Allows for consolidation of notifications at notification group level
{
	objectType: "notificationGroup",
	canDelete: false,
    complexFilterServiceTag: "complexFilter",
	addOnDataStructure: [
		{
			type: "versionedData",
			versionedDataLabel: "notificationGroupSettings",
			storageResourceTag: "myGraph",
			fieldNames: [
				{ // fieldName in versionedData should now same in main objectSchema
			 		fieldName: "notificationGroupName",
			 		type: "string",
					requiredOnCreate: true, 				// default = false
					optionalOnCreate: true, 				// default = false
					canUpdate: true, 						// default = true
					validation: {
						pattern: pattern
					}
				},
				{ 
					fieldName: "consolidated",
			 		type: "boolean",
					requiredOnCreate: true, 				
					optionalOnCreate: true, 				
					canUpdate: true, 						
					validation: {
						pattern: pattern
					}
				},
				{
					fieldName: "consolidatedType",
			 		type: "string",
					requiredOnCreate: true, 				
					optionalOnCreate: true, 				
					canUpdate: true, 						
					validation: {
						pattern: pattern
					}
				},
				{
					fieldName: "consolidatedFrequency",
			 		type: "string",
					requiredOnCreate: true, 				
					optionalOnCreate: true, 				
					canUpdate: true, 						
					validation: {
						pattern: pattern
					}
				},
				{
					fieldName: "consolidatedSendIfEmpty",
			 		type: "boolean",
					requiredOnCreate: true, 				
					optionalOnCreate: true, 				
					canUpdate: true, 						
					validation: {
						pattern: pattern
					}
				}
			]
		}
    ],
    overwriteGeneratedMainFunction: ["create", "get", "update"],
    storageResources: {
		myGraph: {
			storageType: "graph",
			graphServerTag: "GraphHandler"
		}
    },
    fieldNames: { // see Per Service Schemas
		notificationGroupId: {
		    type: "string",
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']
		},
		receiverTag: {
			type: "string",
			requiredOnCreate: true,
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']
		},
		additionalData: {
			type: "object",
			optionalOnCreate: true,
			requiredOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']
		}
    },
    identifiers: [
		{
			type: "identifier",
			fieldName: "notificationGroupId"
		}
    ]
}

fieldNames

notificationGroupId (identifier)
comes from: random UUID
notificationGroupName
string name set by reciever service, optional
additionalData
set by the creating service, gets added to notifications sent to the receiver
eg: can include the actual userId and used to make the groupingId
receiverTag
set by the creating service
eg ContactMethodEmail
consolidated
true|false
optional, if excluded (or value not true), defaults to false
consolidatedType
overview|detailed
overview sends a count of each type of notification, detailed lists each activity message
consolidatedFrequency
not sure, maybe use some sort of standard like cron
consolidatedNextSendDue
timestamp for next due time to send notification
consolidatedSendIfEmpty
true|false


notification

{
	objectType: "notification",
	canDelete: false,
	complexFilterServiceTag: "complexFilter",
	addOnDataStructure: [
		{
			type: "versionedData",
			versionedDataLabel: "notificationSettings",
			storageResourceTag: "myGraph",
			fieldNames: [
				{ // fieldName in versionedData should now same in main objectSchema
			 		fieldName: "notificationName",
			 		type: "string",
					requiredOnCreate: true, 				// default = false
					optionalOnCreate: true, 				// default = false
					canUpdate: true, 						// default = true
					validation: {
						pattern: pattern
					}
				}
			]
		}
    ],
    overwriteGeneratedMainFunction: ["create", "get", "update"],
    storageResources: {
		myGraph: {
			storageType: "graph",
			graphServerTag: "GraphHandler"
		}
    },
    fieldNames: {
		notificationId: {
		    type: "string",
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']
		},
    },
    identifiers: [
		{
			type: "identifier",
			fieldName: "notificationId"
		}
    ]
}

fieldNames

notificationId (identifier)
comes from: random UUID
notificationName
string name set by reciever service, optional


notificationTrigger

{
	objectType: "notificationTrigger",
	canDelete: false,
    complexFilterServiceTag: "complexFilter",
    overwriteGeneratedMainFunction: ["create", "get"],
    storageResources: {
		myGraph: {
			storageType: "graph",
			graphServerTag: "GraphHandler"
		}
    },
    fieldNames: {
		notificationTriggerId: {
			type: "string",
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']
		}
		},
		propertyName: {
			type: "string",
			requiredOnCreate: true,
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']
		},
		valueType: {
			type: "string",
			requiredOnCreate: true,
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']
		},
		value: {
			type: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // can be "string" or "number"
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']		
		},
		values: {
			type: "arrayMixed",
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['myGraph']		
		}
    },
    identifiers: [
		{
			type: "identifier",
			fieldName: "notificationTriggerId"
		}
    ]
}

fieldNames

notificationTriggerId (identifier)
comes from: random UUID
propertyName
can be a nested property, use dot notation
"serviceName" and "topicName" valueTypes do not have propertyName
valueType
property|attribute|serviceName|topicName
value
type: string or number
values
type: array/list of value (arrayMixed??)


consolidated

{
	objectType: "consolidated",
	canDelete: false,
    complexFilterServiceTag: "complexFilter",
    storageResources: {
		dynamoDB: {
			storageType: "dynamoDB",
			graphServerTag: "PendingConsolidation"
		}
    },
    fieldNames: {
		notificationGroupId: {
			type: "string",
			requiredOnCreate: true,
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['dynamoDB']
		},
		time: {
			type: "number",
			requiredOnCreate: true,
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['dynamoDB']		
		},
		activityMsg: {
			type: "object",
			requiredOnCreate: true,
			optionalOnCreate: true,
			canUpdate: false,
			validation: {
				pattern: pattern
			},
			storageResourceTags: ['dynamoDB']		
		}
    },
    identifiers: [
		{
			type: "partitionKey",
			fieldName: "notificationGroupId"
		},
		{
			type: "sortKey",
			fieldName: "time"
		}
    ]
}

fieldNames

notificationGroupId (partition key)
comes from: random UUID
time (sort key)
comes from {timestamp activity handled in Activity Switchboard}_{small random UUID}
adding the UUID to ensure no clashing records with the same timestamp and notificationGroupId
activityMsg
copy of the message delivered from Activity Switchboard


Object Relationships

has_notificationGroup

{
	"has_notificationGroup": {
		properties: {
			originTimestamp: {...}
		},
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "graphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "ContactMethodEmail",					
						objectType: "email"
					},
					linkType: "one",
				},
				to: {
					objType: {
						serviceTag: "NotificationMgr",				
						objType: "notificationGroup"					
					},
					requiredOnCreate: true,					
					linkType: "many",
					handler: true
				}
			}
		]
	}
}
links email to notificationGroup

disabled_notificationGroup

{
	"disabled_notificationGroup": {
		properties: {
			originTimestamp: {...}
		},
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "GraphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "ContactMethodEmail",					
						objectType: "email"
					},
					linkType: "one"
				},
				to: {
					objType: {
						serviceTag: "NotificationMgr",				
						objType: "notificationGroup"					
					},			
					linkType: "many",
					handler: true
				}
			}
		]
	}
}


has_notification

{
	"has_notification": {
		properties: {
			originTimestamp: {...}
		},
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "GraphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "NotificationMgr",					
						objectType: "notificationGroup"
					},
					linkType: "one",
					handler: true					
				},
				to: {
					objType: {
						serviceTag: "NotificationMgr",				
						objType: "notification"					
					},
					requiredOnCreate: true,					
					linkType: "many",
					handler: true
				}
			}
		]
	}
}


disabled_notification

{
	"disabled_notification": {
		properties: {
			originTimestamp: {...}
		},
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "graphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "NotificationMgr",					
						objectType: "notificationGroup"
					},
					linkType: "one",
					handler: true
				},
				to: {
					objType: {
						serviceTag: "NotificationMgr",				
						objType: "notification"					
					},
					linkType: "many",
					handler: true
				}
			}
		]
	}
}


has_notificationTrigger

{
	"has_notificationTrigger": {
		properties: {
			originTimestamp: {...}
		},
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "graphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "NotificationMgr",					
						objectType: "notification"
					},
					linkType: "one",
					handler: true
				},
				to: {
					objType: {
						serviceTag: "NotificationMgr",				
						objType: "notificationTrigger"					
					},
					requiredOnCreate: true,	
					linkType: "many",
					handler: true
				}
			}
		]
	}
}


disabled_notificationTrigger

{
	"disabled_notificationTrigger": {
		properties: {
			originTimestamp: {...}
		},
		storageResources: {
			myGraph: {
				storageType: "graph",
				graphServerTag: "graphHandler"			
			}
		},
		links: [
			{
				storageResourceTags: ["myGraph"],
				from: {
					objType: {
						serviceTag: "NotificationMgr",					
						objectType: "notification"
					},
					linkType: "one",
					handler: true
				},
				to: {
					objType: {
						serviceTag: "NotificationMgr",				
						objType: "notificationTrigger"					
					},
					linkType: "many",
					handler: true
				}
			}
		]
	}
}

value or values array

  • Either 'value' or 'values' should be set, not both, if 'values' is used it means any of the elements in the 'values' array can match.
  • To achieve this on Activity Switchboard a new trigger group is created for each element, each activity group has the full list of other triggers, and one option from this trigger's values array. If a notification has multiple values type triggers than a new trigger group on Activity Switchboard is created for each combination.
  • "serviceName" and "topicName" valueTypes do not have propertyName

serviceName and topicName triggers

  • Notifications do not have to set their serviceName and/or topicName, if not set then any message that matches the properties will pass
  • Can set only the serviceName, then any message that passess the properties and is from that serviceName passes
  • Can set serviceName+topicName, then only messages in that topic will pass
  • serviceName and topicName can both be submitted as "values" array, creating multiple trigger groups for each combination

Consolidated notifications

How to trigger processing for time based consolidations

  • ....
  • maybe can use some sort of queue to store a list of NotificationGroup’s that are due to be sent (either because consolidatedSendIfEmpty == true or there are some activities waiting to be processed)

Formating the notification body

  • Initially the format will be hardwired and simple, but in the future we could create templates for formating the notification body
  • The notificationBody is currently sent to receiver as a JSON stringified object containing all activityMsgs

Ideas

  • overview notifications currently count per notification, but could be extended to do aggregates on a per notification, per field level
  • If set to overview maybe can store just aggregate/s needed for the consolidated notification, at the moment store entire messages, create the overview once when sending notification

Working documents

Working documents - Notification Manager