nip29

package
v0.36.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 5 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetadataEventKinds = KindRange{
	nostr.KindSimpleGroupMetadata,
	nostr.KindSimpleGroupAdmins,
	nostr.KindSimpleGroupMembers,
}
View Source
var ModerationEventKinds = KindRange{
	nostr.KindSimpleGroupAddUser,
	nostr.KindSimpleGroupRemoveUser,
	nostr.KindSimpleGroupEditMetadata,
	nostr.KindSimpleGroupAddPermission,
	nostr.KindSimpleGroupRemovePermission,
	nostr.KindSimpleGroupDeleteEvent,
	nostr.KindSimpleGroupEditGroupStatus,
	nostr.KindSimpleGroupCreateGroup,
	nostr.KindSimpleGroupDeleteGroup,
}

Functions

This section is empty.

Types

type Group

type Group struct {
	Address GroupAddress

	Name    string
	Picture string
	About   string
	Members map[string]*Role
	Private bool
	Closed  bool

	LastMetadataUpdate nostr.Timestamp
	LastAdminsUpdate   nostr.Timestamp
	LastMembersUpdate  nostr.Timestamp
}

func NewGroup

func NewGroup(gadstr string) (Group, error)

NewGroup takes a group address in the form "<id>'<relay-hostname>"

func NewGroupFromMetadataEvent added in v0.33.0

func NewGroupFromMetadataEvent(relayURL string, evt *nostr.Event) (Group, error)

func (*Group) MergeInAdminsEvent

func (group *Group) MergeInAdminsEvent(evt *nostr.Event) error

func (*Group) MergeInMembersEvent

func (group *Group) MergeInMembersEvent(evt *nostr.Event) error

func (*Group) MergeInMetadataEvent

func (group *Group) MergeInMetadataEvent(evt *nostr.Event) error

func (Group) ToAdminsEvent

func (group Group) ToAdminsEvent() *nostr.Event

func (Group) ToMembersEvent

func (group Group) ToMembersEvent() *nostr.Event

func (Group) ToMetadataEvent

func (group Group) ToMetadataEvent() *nostr.Event

type GroupAddress added in v0.31.0

type GroupAddress struct {
	Relay string
	ID    string
}

func ParseGroupAddress added in v0.31.0

func ParseGroupAddress(raw string) (GroupAddress, error)

func (GroupAddress) Equals added in v0.31.0

func (gid GroupAddress) Equals(gid2 GroupAddress) bool

func (GroupAddress) IsValid added in v0.31.0

func (gid GroupAddress) IsValid() bool

func (GroupAddress) String added in v0.31.0

func (gid GroupAddress) String() string

type KindRange

type KindRange []int

func (KindRange) Includes

func (kr KindRange) Includes(kind int) bool

type Permission

type Permission string
const (
	PermAddUser          Permission = "add-user"
	PermEditMetadata     Permission = "edit-metadata"
	PermDeleteEvent      Permission = "delete-event"
	PermRemoveUser       Permission = "remove-user"
	PermAddPermission    Permission = "add-permission"
	PermRemovePermission Permission = "remove-permission"
	PermEditGroupStatus  Permission = "edit-group-status"
	PermDeleteGroup      Permission = "delete-group"
)

type Role

type Role struct {
	Name        string
	Permissions map[Permission]struct{}
}
var (
	// used for normal members without admin powers
	EmptyRole *Role = nil

	PermissionsMap = map[Permission]struct{}{
		PermAddUser:          {},
		PermEditMetadata:     {},
		PermDeleteEvent:      {},
		PermRemoveUser:       {},
		PermAddPermission:    {},
		PermRemovePermission: {},
		PermEditGroupStatus:  {},
	}
)

Jump to

Keyboard shortcuts

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