~emersion/soju-dev

Add detach command to channel update handler v1 PROPOSED

gildarts: 1
 Add detach command to channel update handler

 1 files changed, 6 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/23822/mbox | git am -3
Learn more about email & git
View this thread in the archives

[RFC PATCH] Add detach command to channel update handler Export this patch

---
Trying this as part of the channel update command per IRC conversation.

service.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/service.go b/service.go
index b95f551..a9112ea 100644
--- a/service.go
+++ b/service.go
@@ -286,7 +286,7 @@ func init() {
					handle: handleServiceChannelStatus,
				},
				"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",
					handle: handleServiceChannelUpdate,
				},
@@ -929,11 +929,13 @@ func handleServiceChannelStatus(dc *downstreamConn, params []string) error {

type channelFlagSet struct {
	*flag.FlagSet
	Detached *bool
	RelayDetached, ReattachOn, DetachAfter, DetachOn *string
}

func newChannelFlagSet() *channelFlagSet {
	fs := &channelFlagSet{FlagSet: newFlagSet()}
	fs.Var(boolPtrFlag{&fs.Detached},"detached","")
	fs.Var(stringPtrFlag{&fs.RelayDetached}, "relay-detached", "")
	fs.Var(stringPtrFlag{&fs.ReattachOn}, "reattach-on", "")
	fs.Var(stringPtrFlag{&fs.DetachAfter}, "detach-after", "")
@@ -942,6 +944,9 @@ func newChannelFlagSet() *channelFlagSet {
}

func (fs *channelFlagSet) update(channel *Channel) error {
	if fs.Detached != nil {
		channel.Detached = *fs.Detached
	}
	if fs.RelayDetached != nil {
		filter, err := parseFilter(*fs.RelayDetached)
		if err != nil {
-- 
2.25.1
This updates the detached field in the DB, but there is some
book-keeping that needs to be done when detaching or re-attaching a
channel. See network.detach() and network.attach().