From 9b8cc73bb00dd28ad2fc5a7cc15579a86c83370f Mon Sep 17 00:00:00 2001 From: pschou Date: Sun, 23 Oct 2022 19:47:01 -0400 Subject: [PATCH] feat(userid): add timeout as optional attribute (#94) * add timeout as optional attribute * switch to int --- userid/message.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/userid/message.go b/userid/message.go index 4fb742e4..0efe9e9c 100644 --- a/userid/message.go +++ b/userid/message.go @@ -24,10 +24,11 @@ type Message struct { UntagUsers []UntagUser } -// Login logs a user in. +// Login logs a user in. Note that `Timeout` is in Minutes. type Login struct { - User string - Ip string + User string + Ip string + Timeout int } // Logout logs a user out. @@ -143,6 +144,7 @@ type inOut struct { XMLName xml.Name `xml:"entry"` Name string `xml:"name,attr"` Ip string `xml:"ip,attr"` + Timeout int `xml:"timeout,attr,omitempty"` } type tagUntagIpSpec struct { @@ -201,8 +203,9 @@ func encode(m *Message) (*uid, string) { msg.Payload.Login.Entry = make([]inOut, 0, len(m.Logins)) for i := range m.Logins { x := inOut{ - Name: m.Logins[i].User, - Ip: m.Logins[i].Ip, + Name: m.Logins[i].User, + Ip: m.Logins[i].Ip, + Timeout: m.Logins[i].Timeout, } msg.Payload.Login.Entry = append(msg.Payload.Login.Entry, x) }