replace "no-text" with "supported_kinds".
This commit is contained in:
+23
-14
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
@@ -55,12 +56,12 @@ type Group struct {
|
|||||||
// indicates that relays should hide group metadata from non-members
|
// indicates that relays should hide group metadata from non-members
|
||||||
Hidden bool
|
Hidden bool
|
||||||
|
|
||||||
// indicates that text messages are not allowed in the group
|
|
||||||
NoText bool
|
|
||||||
|
|
||||||
// indicates that the group supports audio/video live chat
|
// indicates that the group supports audio/video live chat
|
||||||
Livekit bool
|
Livekit bool
|
||||||
|
|
||||||
|
// indicates which event kinds this group supports
|
||||||
|
SupportedKinds []nostr.Kind
|
||||||
|
|
||||||
Roles []*Role
|
Roles []*Role
|
||||||
InviteCodes []string
|
InviteCodes []string
|
||||||
|
|
||||||
@@ -75,7 +76,6 @@ func (group Group) String() string {
|
|||||||
maybeRestricted := ""
|
maybeRestricted := ""
|
||||||
maybeHidden := ""
|
maybeHidden := ""
|
||||||
maybeClosed := ""
|
maybeClosed := ""
|
||||||
maybeNoText := ""
|
|
||||||
|
|
||||||
if group.Private {
|
if group.Private {
|
||||||
maybePrivate = " private"
|
maybePrivate = " private"
|
||||||
@@ -89,9 +89,6 @@ func (group Group) String() string {
|
|||||||
if group.Closed {
|
if group.Closed {
|
||||||
maybeClosed = " closed"
|
maybeClosed = " closed"
|
||||||
}
|
}
|
||||||
if group.NoText {
|
|
||||||
maybeNoText = " no-text"
|
|
||||||
}
|
|
||||||
|
|
||||||
maybeLivekit := ""
|
maybeLivekit := ""
|
||||||
if group.Livekit {
|
if group.Livekit {
|
||||||
@@ -123,7 +120,6 @@ func (group Group) String() string {
|
|||||||
maybeRestricted,
|
maybeRestricted,
|
||||||
maybeHidden,
|
maybeHidden,
|
||||||
maybeClosed,
|
maybeClosed,
|
||||||
maybeNoText,
|
|
||||||
maybeLivekit,
|
maybeLivekit,
|
||||||
group.Picture,
|
group.Picture,
|
||||||
group.About,
|
group.About,
|
||||||
@@ -190,14 +186,19 @@ func (group Group) ToMetadataEvent() nostr.Event {
|
|||||||
if group.Closed {
|
if group.Closed {
|
||||||
evt.Tags = append(evt.Tags, nostr.Tag{"closed"})
|
evt.Tags = append(evt.Tags, nostr.Tag{"closed"})
|
||||||
}
|
}
|
||||||
if group.NoText {
|
|
||||||
evt.Tags = append(evt.Tags, nostr.Tag{"no-text"})
|
|
||||||
}
|
|
||||||
|
|
||||||
if group.Livekit {
|
if group.Livekit {
|
||||||
evt.Tags = append(evt.Tags, nostr.Tag{"livekit"})
|
evt.Tags = append(evt.Tags, nostr.Tag{"livekit"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if group.SupportedKinds != nil {
|
||||||
|
tag := make(nostr.Tag, 1, 1+len(group.SupportedKinds))
|
||||||
|
tag[0] = "supported_kinds"
|
||||||
|
for _, kind := range group.SupportedKinds {
|
||||||
|
tag = append(tag, strconv.Itoa(int(kind)))
|
||||||
|
}
|
||||||
|
evt.Tags = append(evt.Tags, tag)
|
||||||
|
}
|
||||||
|
|
||||||
return evt
|
return evt
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,10 +283,18 @@ func (group *Group) MergeInMetadataEvent(evt *nostr.Event) error {
|
|||||||
group.Closed = true
|
group.Closed = true
|
||||||
case "hidden":
|
case "hidden":
|
||||||
group.Hidden = true
|
group.Hidden = true
|
||||||
case "no-text":
|
|
||||||
group.NoText = true
|
|
||||||
case "livekit":
|
case "livekit":
|
||||||
group.Livekit = true
|
group.Livekit = true
|
||||||
|
case "supported_kinds":
|
||||||
|
kinds := make([]nostr.Kind, 0, len(tag)-1)
|
||||||
|
for _, raw := range tag[1:] {
|
||||||
|
kind, err := strconv.Atoi(raw)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
kinds = append(kinds, nostr.Kind(kind))
|
||||||
|
}
|
||||||
|
group.SupportedKinds = kinds
|
||||||
default:
|
default:
|
||||||
if len(tag) >= 2 {
|
if len(tag) >= 2 {
|
||||||
switch tag[0] {
|
switch tag[0] {
|
||||||
|
|||||||
@@ -123,12 +123,6 @@ var moderationActionFactories = map[nostr.Kind]func(nostr.Event) (Action, error)
|
|||||||
case "public":
|
case "public":
|
||||||
edit.PrivateValue = &n
|
edit.PrivateValue = &n
|
||||||
ok = true
|
ok = true
|
||||||
case "no-text":
|
|
||||||
edit.NoTextValue = &y
|
|
||||||
ok = true
|
|
||||||
case "text":
|
|
||||||
edit.NoTextValue = &n
|
|
||||||
ok = true
|
|
||||||
case "livekit":
|
case "livekit":
|
||||||
edit.LivekitValue = &y
|
edit.LivekitValue = &y
|
||||||
ok = true
|
ok = true
|
||||||
@@ -250,7 +244,6 @@ type EditMetadata struct {
|
|||||||
ClosedValue *bool
|
ClosedValue *bool
|
||||||
HiddenValue *bool
|
HiddenValue *bool
|
||||||
PrivateValue *bool
|
PrivateValue *bool
|
||||||
NoTextValue *bool
|
|
||||||
LivekitValue *bool
|
LivekitValue *bool
|
||||||
When nostr.Timestamp
|
When nostr.Timestamp
|
||||||
}
|
}
|
||||||
@@ -279,9 +272,6 @@ func (a EditMetadata) Apply(group *Group) {
|
|||||||
if a.PrivateValue != nil {
|
if a.PrivateValue != nil {
|
||||||
group.Private = *a.PrivateValue
|
group.Private = *a.PrivateValue
|
||||||
}
|
}
|
||||||
if a.NoTextValue != nil {
|
|
||||||
group.NoText = *a.NoTextValue
|
|
||||||
}
|
|
||||||
if a.LivekitValue != nil {
|
if a.LivekitValue != nil {
|
||||||
group.Livekit = *a.LivekitValue
|
group.Livekit = *a.LivekitValue
|
||||||
}
|
}
|
||||||
@@ -310,7 +300,6 @@ func (a DeleteGroup) Apply(group *Group) {
|
|||||||
group.Private = true
|
group.Private = true
|
||||||
group.Restricted = true
|
group.Restricted = true
|
||||||
group.Hidden = true
|
group.Hidden = true
|
||||||
group.NoText = true
|
|
||||||
group.Name = "[deleted]"
|
group.Name = "[deleted]"
|
||||||
group.About = ""
|
group.About = ""
|
||||||
group.Picture = ""
|
group.Picture = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user