Skip to content
Snippets Groups Projects
Commit 3db3dcf5 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add GetDmNotificationReportsForMe

parent b627a572
No related branches found
No related tags found
2 merge requests!132Add Support for Multiple Listeners,!109Project/haven beta
......@@ -808,6 +808,59 @@ func DecodeDMShareURL(_ js.Value, args []js.Value) any {
return utils.CopyBytesToJS(report)
}
// GetDmNotificationReportsForMe checks the notification data against the filter
// list to determine which notifications belong to the user. A list of
// notification reports is returned detailing all notifications for the user.
//
// Parameters:
// - args[0] - notificationFilterJSON - JSON (Uint8Array) of
// [dm.NotificationFilter].
// - args[1] - notificationDataCSV - CSV containing notification data.
//
// Example JSON of a slice of [dm.NotificationFilter]:
//
// {
// "identifier": "MWL6mvtZ9UUm7jP3ainyI4erbRl+wyVaO5MOWboP0rA=",
// "myID": "AqDqg6Tcs359dBNRBCX7XHaotRDhz1ZRQNXIsGaubvID",
// "tags": [
// "61334HtH85DPIifvrM+JzRmLqfV5R4AMEmcPelTmFX0=",
// "zc/EPwtx5OKTVdwLcI15bghjJ7suNhu59PcarXE+m9o=",
// "FvArzVJ/082UEpMDCWJsopCLeLnxJV6NXINNkJTk3k8="
// ],
// "PublicKeys": {
// "61334HtH85DPIifvrM+JzRmLqfV5R4AMEmcPelTmFX0=": "b3HygDv8gjteune9wgBm3YtVuAo2foOusRmj0m5nl6E=",
// "FvArzVJ/082UEpMDCWJsopCLeLnxJV6NXINNkJTk3k8=": "uOLitBZcCh2TEW406jXHJ+Rsi6LybsH8R1u4Mxv/7hA=",
// "zc/EPwtx5OKTVdwLcI15bghjJ7suNhu59PcarXE+m9o=": "lqLD1EzZBxB8PbILUJIfFq4JI0RKThpUQuNlTNgZAWk="
// },
// "allowedTypes": {"1": {}, "2": {}}
// }
//
// Returns:
// - []byte - JSON of a slice of [dm.NotificationReport].
//
// Example return:
//
// [
// {"partner": "WUSO3trAYeBf4UeJ5TEL+Q4usoyFf0shda0YUmZ3z8k=", "type": 1},
// {"partner": "5MY652JsVv5YLE6wGRHIFZBMvLklACnT5UtHxmEOJ4o=", "type": 2}
// ]
func GetDmNotificationReportsForMe(_ js.Value, args []js.Value) any {
notificationFilterJson := utils.CopyBytesToGo(args[0])
notificationDataCsv := args[1].String()
promiseFn := func(resolve, reject func(args ...any) js.Value) {
forme, err := bindings.GetDmNotificationReportsForMe(
notificationFilterJson, notificationDataCsv)
if err != nil {
reject(exception.NewTrace(err))
} else {
resolve(utils.CopyBytesToJS(forme))
}
}
return utils.CreatePromise(promiseFn)
}
////////////////////////////////////////////////////////////////////////////////
// Event Model Logic //
////////////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment