From b627a572c39281313fe717734ebebf47b4e34ccd Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Wed, 14 Jun 2023 18:01:17 +0000
Subject: [PATCH] Fix tests

---
 wasm/dm.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/wasm/dm.go b/wasm/dm.go
index a6ae74ca..f314143d 100644
--- a/wasm/dm.go
+++ b/wasm/dm.go
@@ -65,6 +65,11 @@ func newDMClientJS(api *bindings.DMClient) map[string]any {
 		"SendReaction": js.FuncOf(cm.SendReaction),
 		"SendSilent":   js.FuncOf(cm.SendSilent),
 		"Send":         js.FuncOf(cm.Send),
+
+		// Notifications
+		"GetNotificationLevel": js.FuncOf(cm.GetNotificationLevel),
+		"SetMobileNotificationsLevel": js.FuncOf(
+			cm.SetMobileNotificationsLevel),
 	}
 
 	return dmClientMap
@@ -737,6 +742,53 @@ func (dmc *DMClient) GetShareURL(_ js.Value, args []js.Value) any {
 	return utils.CopyBytesToJS(urlReport)
 }
 
+// GetNotificationLevel Gets the notification level for a given dm pubkey
+//
+// Parameters:
+//   - args[0] - partnerPublic key (Uint8Array)
+//
+// Returns:
+//   - int of notification level
+func (d *DMClient) GetNotificationLevel(_ js.Value, args []js.Value) any {
+	partnerPubKey := utils.CopyBytesToGo(args[0])
+
+	promiseFn := func(resolve, reject func(args ...any) js.Value) {
+		level, err := d.api.GetNotificationLevel(partnerPubKey)
+		if err != nil {
+			reject(exception.NewTrace(err))
+		} else {
+			resolve(level)
+		}
+	}
+
+	return utils.CreatePromise(promiseFn)
+}
+
+// SetMobileNotificationsLevel sets the notification level for a given pubkey.
+//
+// Parameters:
+//   - args[0] - partnerPublicKey (Uint8Array)
+//   - args[1] - the notification level (integer)
+//
+// Returns:
+//   - error or nothing
+func (d *DMClient) SetMobileNotificationsLevel(_ js.Value,
+	args []js.Value) any {
+	partnerPubKey := utils.CopyBytesToGo(args[0])
+	level := args[1].Int()
+
+	promiseFn := func(resolve, reject func(args ...any) js.Value) {
+		err := d.api.SetMobileNotificationsLevel(partnerPubKey, level)
+		if err != nil {
+			reject(exception.NewTrace(err))
+		} else {
+			resolve()
+		}
+	}
+
+	return utils.CreatePromise(promiseFn)
+}
+
 // DecodeDMShareURL decodes the user's URL into a [DMUser].
 //
 // Parameters:
-- 
GitLab