3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00

remove client join time tracking

This commit is contained in:
Shivaram Lingamneni 2020-06-12 17:13:47 -04:00
parent 18fd86ce98
commit bfeba1f2f3
2 changed files with 6 additions and 23 deletions

View File

@ -30,7 +30,6 @@ type Channel struct {
key string
members MemberSet
membersCache []*Client // allow iteration over channel members without holding the lock
memberJoinTimes map[*Client]time.Time
name string
nameCasefolded string
server *Server
@ -60,7 +59,6 @@ func NewChannel(s *Server, name, casefoldedName string, registered bool) *Channe
channel := &Channel{
createdTime: time.Now().UTC(), // may be overwritten by applyRegInfo
members: make(MemberSet),
memberJoinTimes: make(map[*Client]time.Time),
name: name,
nameCasefolded: casefoldedName,
server: s,
@ -553,13 +551,6 @@ func (channel *Channel) ClientModeStrings(client *Client) (result []string) {
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 {
channel.stateMutex.RLock()
founder := channel.registeredFounder
@ -736,7 +727,6 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
defer channel.stateMutex.Unlock()
channel.members.Add(client)
channel.memberJoinTimes[client] = time.Now().UTC()
firstJoin := len(channel.members) == 1
newChannel := firstJoin && channel.registeredFounder == ""
if newChannel {
@ -1375,7 +1365,6 @@ func (channel *Channel) Quit(client *Client) {
channel.stateMutex.Lock()
channel.members.Remove(client)
delete(channel.memberJoinTimes, client)
channelEmpty := len(channel.members) == 0
channel.stateMutex.Unlock()
channel.regenerateMembersCache()

View File

@ -939,13 +939,7 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
claims["joined"] = 0
claims["cmodes"] = []string{}
if channel.hasClient(client) {
joinTime := channel.ClientJoinTime(client)
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["joined"] = 1
claims["cmodes"] = channel.ClientModeStrings(client)
}
}