mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
remove client join time tracking
This commit is contained in:
parent
18fd86ce98
commit
bfeba1f2f3
@ -30,7 +30,6 @@ type Channel struct {
|
|||||||
key string
|
key string
|
||||||
members MemberSet
|
members MemberSet
|
||||||
membersCache []*Client // allow iteration over channel members without holding the lock
|
membersCache []*Client // allow iteration over channel members without holding the lock
|
||||||
memberJoinTimes map[*Client]time.Time
|
|
||||||
name string
|
name string
|
||||||
nameCasefolded string
|
nameCasefolded string
|
||||||
server *Server
|
server *Server
|
||||||
@ -58,12 +57,11 @@ func NewChannel(s *Server, name, casefoldedName string, registered bool) *Channe
|
|||||||
config := s.Config()
|
config := s.Config()
|
||||||
|
|
||||||
channel := &Channel{
|
channel := &Channel{
|
||||||
createdTime: time.Now().UTC(), // may be overwritten by applyRegInfo
|
createdTime: time.Now().UTC(), // may be overwritten by applyRegInfo
|
||||||
members: make(MemberSet),
|
members: make(MemberSet),
|
||||||
memberJoinTimes: make(map[*Client]time.Time),
|
name: name,
|
||||||
name: name,
|
nameCasefolded: casefoldedName,
|
||||||
nameCasefolded: casefoldedName,
|
server: s,
|
||||||
server: s,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.initializeLists()
|
channel.initializeLists()
|
||||||
@ -553,13 +551,6 @@ func (channel *Channel) ClientModeStrings(client *Client) (result []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) ClientJoinTime(client *Client) time.Time {
|
|
||||||
channel.stateMutex.RLock()
|
|
||||||
defer channel.stateMutex.RUnlock()
|
|
||||||
time := channel.memberJoinTimes[client]
|
|
||||||
return time
|
|
||||||
}
|
|
||||||
|
|
||||||
func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool {
|
func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool {
|
||||||
channel.stateMutex.RLock()
|
channel.stateMutex.RLock()
|
||||||
founder := channel.registeredFounder
|
founder := channel.registeredFounder
|
||||||
@ -736,7 +727,6 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
|
|||||||
defer channel.stateMutex.Unlock()
|
defer channel.stateMutex.Unlock()
|
||||||
|
|
||||||
channel.members.Add(client)
|
channel.members.Add(client)
|
||||||
channel.memberJoinTimes[client] = time.Now().UTC()
|
|
||||||
firstJoin := len(channel.members) == 1
|
firstJoin := len(channel.members) == 1
|
||||||
newChannel := firstJoin && channel.registeredFounder == ""
|
newChannel := firstJoin && channel.registeredFounder == ""
|
||||||
if newChannel {
|
if newChannel {
|
||||||
@ -1375,7 +1365,6 @@ func (channel *Channel) Quit(client *Client) {
|
|||||||
|
|
||||||
channel.stateMutex.Lock()
|
channel.stateMutex.Lock()
|
||||||
channel.members.Remove(client)
|
channel.members.Remove(client)
|
||||||
delete(channel.memberJoinTimes, client)
|
|
||||||
channelEmpty := len(channel.members) == 0
|
channelEmpty := len(channel.members) == 0
|
||||||
channel.stateMutex.Unlock()
|
channel.stateMutex.Unlock()
|
||||||
channel.regenerateMembersCache()
|
channel.regenerateMembersCache()
|
||||||
|
@ -939,13 +939,7 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
claims["joined"] = 0
|
claims["joined"] = 0
|
||||||
claims["cmodes"] = []string{}
|
claims["cmodes"] = []string{}
|
||||||
if channel.hasClient(client) {
|
if channel.hasClient(client) {
|
||||||
joinTime := channel.ClientJoinTime(client)
|
claims["joined"] = 1
|
||||||
if joinTime.IsZero() {
|
|
||||||
// shouldn't happen, only in races
|
|
||||||
rb.Add(nil, server.name, "FAIL", "EXTJWT", "UNKNOWN_ERROR", client.t("Channel join time is inconsistent, JWT not generated"))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
claims["joined"] = joinTime.Unix()
|
|
||||||
claims["cmodes"] = channel.ClientModeStrings(client)
|
claims["cmodes"] = channel.ClientModeStrings(client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user