Add detach option to channel update
Add `-detached` to `channel update` command Co-authored-by: Simon Ser <contact@emersion.fr> Closes: https://todo.sr.ht/~emersion/soju/140
This commit is contained in:
parent
ca3557d9ef
commit
4bc9aaf659
@ -283,6 +283,13 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
|
|||||||
|
|
||||||
Options are:
|
Options are:
|
||||||
|
|
||||||
|
*-detached* true|false
|
||||||
|
Attach or detach this channel.
|
||||||
|
|
||||||
|
A detached channel is joined but is hidden by the bouncer. This is
|
||||||
|
useful to e.g. collect logs and highlights in low-interest or
|
||||||
|
high-traffic channels.
|
||||||
|
|
||||||
*-relay-detached* <mode>
|
*-relay-detached* <mode>
|
||||||
Set when to relay messages from detached channels to the user with a BouncerServ NOTICE.
|
Set when to relay messages from detached channels to the user with a BouncerServ NOTICE.
|
||||||
|
|
||||||
|
12
service.go
12
service.go
@ -288,7 +288,7 @@ func init() {
|
|||||||
handle: handleServiceChannelStatus,
|
handle: handleServiceChannelStatus,
|
||||||
},
|
},
|
||||||
"update": {
|
"update": {
|
||||||
usage: "<name> [-relay-detached <default|none|highlight|message>] [-reattach-on <default|none|highlight|message>] [-detach-after <duration>] [-detach-on <default|none|highlight|message>]",
|
usage: "<name> [-detached <true|false>] [-relay-detached <default|none|highlight|message>] [-reattach-on <default|none|highlight|message>] [-detach-after <duration>] [-detach-on <default|none|highlight|message>]",
|
||||||
desc: "update a channel",
|
desc: "update a channel",
|
||||||
handle: handleServiceChannelUpdate,
|
handle: handleServiceChannelUpdate,
|
||||||
},
|
},
|
||||||
@ -1048,11 +1048,13 @@ func parseFilter(filter string) (database.MessageFilter, error) {
|
|||||||
|
|
||||||
type channelFlagSet struct {
|
type channelFlagSet struct {
|
||||||
*flag.FlagSet
|
*flag.FlagSet
|
||||||
|
Detached *bool
|
||||||
RelayDetached, ReattachOn, DetachAfter, DetachOn *string
|
RelayDetached, ReattachOn, DetachAfter, DetachOn *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newChannelFlagSet() *channelFlagSet {
|
func newChannelFlagSet() *channelFlagSet {
|
||||||
fs := &channelFlagSet{FlagSet: newFlagSet()}
|
fs := &channelFlagSet{FlagSet: newFlagSet()}
|
||||||
|
fs.Var(boolPtrFlag{&fs.Detached}, "detached", "")
|
||||||
fs.Var(stringPtrFlag{&fs.RelayDetached}, "relay-detached", "")
|
fs.Var(stringPtrFlag{&fs.RelayDetached}, "relay-detached", "")
|
||||||
fs.Var(stringPtrFlag{&fs.ReattachOn}, "reattach-on", "")
|
fs.Var(stringPtrFlag{&fs.ReattachOn}, "reattach-on", "")
|
||||||
fs.Var(stringPtrFlag{&fs.DetachAfter}, "detach-after", "")
|
fs.Var(stringPtrFlag{&fs.DetachAfter}, "detach-after", "")
|
||||||
@ -1117,6 +1119,14 @@ func handleServiceChannelUpdate(ctx context.Context, dc *downstreamConn, params
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fs.Detached != nil && *fs.Detached != ch.Detached {
|
||||||
|
if *fs.Detached {
|
||||||
|
uc.network.detach(ch)
|
||||||
|
} else {
|
||||||
|
uc.network.attach(ctx, ch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uc.updateChannelAutoDetach(upstreamName)
|
uc.updateChannelAutoDetach(upstreamName)
|
||||||
|
|
||||||
if err := dc.srv.db.StoreChannel(ctx, uc.network.ID, ch); err != nil {
|
if err := dc.srv.db.StoreChannel(ctx, uc.network.ID, ch); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user