hybrid

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

This file contains all code related to how a Group Manager operates over a group. Managed groups are canonically controlled by members setting the ManageGroup permission in the conversation ACL; allowing the manager to take control of how this group is structured, see OnEvent below... TODO: This file represents stage 1 of the roll out which de-risks most of the integration into cwtch peer, new interfaces, and UI integration The following functionality is not yet implemented: - group-level encryption - key rotation / membership ACL Cwtch Hybrid Groups are still very experimental functionality and should only be used for testing purposes.

Index

Constants

View Source
const (
	MemberGroupIDKey   = "member_group_id_key"
	MemberMessageIDKey = "member_group_messge_id"
)
View Source
const (
	AddMember       = GroupEventType(0x1000)
	RemoveMember    = GroupEventType(0x2000)
	RotateKey       = GroupEventType(0x3000)
	NewMessage      = GroupEventType(0x4000)
	NewClearMessage = GroupEventType(0x5000)
	SyncRequest     = GroupEventType(0x6000)
)
View Source
const MANAGED_GROUP_HANDLE = "managed:000"

MANAGED_GROUP_HANDLE denotes the nominal name that the managed group is given, for easier handling Note: we could use id here, as the managed group should technically always be the first group But we don't want to assume that, and also allow conversations to be moved around without constantly referring to a magic id.

View Source
const ManagedGroupOpen = "managed-group-open"

Variables

This section is empty.

Functions

func AuthenticateMessage

func AuthenticateMessage(message HybridGroupMessage) bool

AuthenticateMessage returns true if the Author of the message produced the Signature over the message

func CheckACL

func CheckACL(handle string, group *model.Conversation) (*model.AccessControl, error)

Types

type AddMemberEvent

type AddMemberEvent struct {
	Handle string `json:"h"`
}

type GroupEventType

type GroupEventType int

type GroupManagerFunctionality

type GroupManagerFunctionality struct {
}

func (*GroupManagerFunctionality) AddHybridContact

func (f *GroupManagerFunctionality) AddHybridContact(profile peer.CwtchPeer, handle string) error

AddHybridContact is a wrapper arround NewContactConversation which sets the contact up for Hybrid Group channel messages... TODO this function assumes that authorization has been done at a higher level..

func (*GroupManagerFunctionality) EventsToRegister

func (f *GroupManagerFunctionality) EventsToRegister() []event.Type

func (*GroupManagerFunctionality) ExperimentsToRegister

func (f *GroupManagerFunctionality) ExperimentsToRegister() []string

func (*GroupManagerFunctionality) GetManagedGroup

func (f *GroupManagerFunctionality) GetManagedGroup(profile peer.CwtchPeer) (*model.Conversation, error)

GetManagedGroup is a convieniance function that looks up the managed group

func (*GroupManagerFunctionality) ManageNewGroup

func (f *GroupManagerFunctionality) ManageNewGroup(profile peer.CwtchPeer) (int, error)

Establish a new Managed Group and return its conversation id

func (*GroupManagerFunctionality) NotifySettingsUpdate

func (f *GroupManagerFunctionality) NotifySettingsUpdate(settings settings.GlobalSettings)

func (*GroupManagerFunctionality) OnContactReceiveValue

func (f *GroupManagerFunctionality) OnContactReceiveValue(profile peer.CwtchPeer, conversation model.Conversation, path attr.ScopedZonedPath, value string, exists bool)

func (*GroupManagerFunctionality) OnContactRequestValue

func (f *GroupManagerFunctionality) OnContactRequestValue(profile peer.CwtchPeer, conversation model.Conversation, eventID string, path attr.ScopedZonedPath)

func (*GroupManagerFunctionality) OnEvent

func (f *GroupManagerFunctionality) OnEvent(ev event.Event, profile peer.CwtchPeer)

OnEvent handles File Sharing Hooks like Manifest Received and FileDownloaded

func (*GroupManagerFunctionality) SetMembershipClosed added in v0.28.4

func (f *GroupManagerFunctionality) SetMembershipClosed(profile peer.CwtchPeer) error

func (*GroupManagerFunctionality) SetMembershipOpen added in v0.28.4

func (f *GroupManagerFunctionality) SetMembershipOpen(profile peer.CwtchPeer) error

type HybridGroupMessage

type HybridGroupMessage struct {
	Author          string `json:"a"` // the authors cwtch address
	MemberGroupID   uint32 `json:"g"`
	MemberMessageID uint32 `json:"m"`
	MessageBody     string `json:"b"`
	Sent            uint64 `json:"t"` // milliseconds since epoch
	Signature       []byte `json:"s"` // of json-encoded content (including empty sig)
}

This file contains code for the Hybrid Group / Managed Group types..

type ManageGroupEvent

type ManageGroupEvent struct {
	EventType GroupEventType `json:"t"`
	Data      string         `json:"d"` // json encoded data
}

type ManagedGroupFunctionality

type ManagedGroupFunctionality struct {
}

func (ManagedGroupFunctionality) EventsToRegister

func (f ManagedGroupFunctionality) EventsToRegister() []event.Type

func (ManagedGroupFunctionality) ExperimentsToRegister

func (f ManagedGroupFunctionality) ExperimentsToRegister() []string

func (*ManagedGroupFunctionality) NewManagedGroup

func (f *ManagedGroupFunctionality) NewManagedGroup(profile peer.CwtchPeer, manager string) error

Define a new managed group, managed by the manager...

func (ManagedGroupFunctionality) NotifySettingsUpdate

func (f ManagedGroupFunctionality) NotifySettingsUpdate(settings settings.GlobalSettings)

func (ManagedGroupFunctionality) OnContactReceiveValue

func (f ManagedGroupFunctionality) OnContactReceiveValue(profile peer.CwtchPeer, conversation model.Conversation, path attr.ScopedZonedPath, value string, exists bool)

func (ManagedGroupFunctionality) OnContactRequestValue

func (f ManagedGroupFunctionality) OnContactRequestValue(profile peer.CwtchPeer, conversation model.Conversation, eventID string, path attr.ScopedZonedPath)

func (*ManagedGroupFunctionality) OnEvent

func (f *ManagedGroupFunctionality) OnEvent(ev event.Event, profile peer.CwtchPeer)

OnEvent handles File Sharing Hooks like Manifest Received and FileDownloaded

func (*ManagedGroupFunctionality) SendMessageToManagedGroup

func (f *ManagedGroupFunctionality) SendMessageToManagedGroup(profile peer.CwtchPeer, conversation int, message string) (int, error)

SendMessageToManagedGroup acts like SendMessage(ToPeer), but with a few additional bookkeeping steps for Hybrid Groups

type NewClearMessageEvent

type NewClearMessageEvent struct {
	HybridGroupMessage HybridGroupMessage `json:"m"`
}

type NewMessageEvent

type NewMessageEvent struct {
	EncryptedHybridGroupMessage []byte `json:"m"`
}

type RemoveMemberEvent

type RemoveMemberEvent struct {
	Handle string `json:"h"`
}

type RotateKeyEvent

type RotateKeyEvent struct {
	Key []byte `json:"k"`
}

type SyncRequestMessage

type SyncRequestMessage struct {
	// a map of MemberGroupID: MemberMessageID
	LastSeen map[int]int `json:"l"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL