From 547a2b56a19cd4852f051b430ecb30e13e7a1d5d Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Fri, 14 Jan 2022 22:46:04 +0000
Subject: [PATCH] Add URL to dashboard functionality for round IDs

---
 bindings/group.go   | 10 ++++++++++
 bindings/message.go |  5 +++++
 bindings/send.go    |  7 +++++++
 bindings/url.go     | 20 ++++++++++++++++++++
 4 files changed, 42 insertions(+)
 create mode 100644 bindings/url.go

diff --git a/bindings/group.go b/bindings/group.go
index e0da4aff7..aee0b0f7c 100644
--- a/bindings/group.go
+++ b/bindings/group.go
@@ -263,6 +263,11 @@ func (gsr *GroupSendReport) GetMessageID() []byte {
 	return gsr.messageID[:]
 }
 
+// GetRoundURL returns the URL of the round that the send occurred on.
+func (gsr *GroupSendReport) GetRoundURL() string {
+	return getRoundURL(gsr.roundID)
+}
+
 ////
 // Group Structure
 ////
@@ -413,6 +418,11 @@ func (gmr *GroupMessageReceive) GetRoundID() int64 {
 	return int64(gmr.RoundID)
 }
 
+// GetRoundURL returns the ID of the round the message was sent on.
+func (gmr *GroupMessageReceive) GetRoundURL() string {
+	return getRoundURL(gmr.RoundID)
+}
+
 // GetRoundTimestampNano returns the timestamp, in nanoseconds, of the round the
 // message was sent on.
 func (gmr *GroupMessageReceive) GetRoundTimestampNano() int64 {
diff --git a/bindings/message.go b/bindings/message.go
index 680d9caf7..3eee3b343 100644
--- a/bindings/message.go
+++ b/bindings/message.go
@@ -65,3 +65,8 @@ func (m *Message) GetRoundTimestampNano() int64 {
 func (m *Message) GetRoundId() int64 {
 	return int64(m.r.RoundId)
 }
+
+// GetRoundURL returns the message's round URL
+func (m *Message) GetRoundURL() string {
+	return getRoundURL(m.r.RoundId)
+}
diff --git a/bindings/send.go b/bindings/send.go
index be9366974..3b85a34b0 100644
--- a/bindings/send.go
+++ b/bindings/send.go
@@ -199,6 +199,13 @@ func (sr *SendReport) GetMessageID() []byte {
 	return sr.mid[:]
 }
 
+func (sr *SendReport) GetRoundURL() string {
+	if sr.rl != nil && sr.rl.Len() > 0 {
+		return getRoundURL(sr.rl.list[0])
+	}
+	return dashboardBaseURL
+}
+
 // GetTimestampMS returns the message's timestamp in milliseconds
 func (sr *SendReport) GetTimestampMS() int64 {
 	ts := sr.ts.UnixNano()
diff --git a/bindings/url.go b/bindings/url.go
new file mode 100644
index 000000000..9c7092cf5
--- /dev/null
+++ b/bindings/url.go
@@ -0,0 +1,20 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright © 2020 xx network SEZC                                          //
+//                                                                           //
+// Use of this source code is governed by a license that can be found in the //
+// LICENSE file                                                              //
+///////////////////////////////////////////////////////////////////////////////
+
+package bindings
+
+
+import (
+	"gitlab.com/xx_network/primitives/id"
+	"fmt"
+)
+
+const dashboardBaseURL = "https://dashboard.xx.network"
+
+func getRoundURL(round id.Round) string {
+	return fmt.Sprintf("%s/rounds/%d", dashboardBaseURL, round)
+}
-- 
GitLab