From 9b6db62dd9f10747c6dcf67f0553ceee829c7ac2 Mon Sep 17 00:00:00 2001 From: Benjamin Wenger <ben@elixxir.ioo> Date: Tue, 30 Aug 2022 16:35:25 -0700 Subject: [PATCH] added a channels package docstring --- channels/errors.go | 2 ++ channels/eventModel.go | 10 ++++------ channels/interface.go | 4 ++++ channels/manager.go | 3 +++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/channels/errors.go b/channels/errors.go index 6d926af93..dd941f86a 100644 --- a/channels/errors.go +++ b/channels/errors.go @@ -18,4 +18,6 @@ var ( "the passed message is too long") WrongPrivateKey = errors.New( "the passed private key does not match the channel") + MessageTypeAlreadyRegistered = errors.New("the given message type has " + + "already been registered") ) diff --git a/channels/eventModel.go b/channels/eventModel.go index 21a14d239..23db8e082 100644 --- a/channels/eventModel.go +++ b/channels/eventModel.go @@ -8,7 +8,6 @@ package channels import ( - "errors" "github.com/golang/protobuf/proto" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/cmix/identity/receptionID" @@ -22,13 +21,10 @@ import ( "gitlab.com/xx_network/primitives/id" ) +// AdminUsername defines the displayed username of admin messages, which are +// unique users for every channel defined by the channel's private key const AdminUsername = "Admin" -var ( - MessageTypeAlreadyRegistered = errors.New("the given message type has " + - "already been registered") -) - // EventModel is an interface which an external party which uses the channels // system passed an object which adheres to in order to get events on the channel type EventModel interface { @@ -72,6 +68,8 @@ type EventModel interface { //UnPinMessage(ChannelID *id.ID, MessageID cryptoChannel.MessageID) } +// MessageTypeReceiveMessage defines handlers for messages of various message +// types. Default ones for Text, Reaction, and AdminText. type MessageTypeReceiveMessage func(channelID *id.ID, messageID cryptoChannel.MessageID, messageType MessageType, senderUsername string, content []byte, timestamp time.Time, diff --git a/channels/interface.go b/channels/interface.go index 38b1f8170..ac07646c0 100644 --- a/channels/interface.go +++ b/channels/interface.go @@ -17,6 +17,10 @@ import ( "time" ) +// ValidForever is used as a validUntil lease when sending to denote the +// message or operation never expires. Note: A message relay must be +// present to enforce this otherwise things expire after 3 weeks due to +// network retention. var ValidForever = time.Duration(math.MaxInt64) type Manager interface { diff --git a/channels/manager.go b/channels/manager.go index 66e112a35..1600271af 100644 --- a/channels/manager.go +++ b/channels/manager.go @@ -5,6 +5,9 @@ // LICENSE file // //////////////////////////////////////////////////////////////////////////////// +// Package channels provides a channels implementation on top of broadcast +// which is capable of handing the user facing features of channels, including +// replies, reactions, and eventually admin commands. package channels import ( -- GitLab