|
@@ -376,10 +376,12 @@ func (client *Client) TryResume() {
|
376
|
376
|
|
377
|
377
|
// apply old client's details to new client
|
378
|
378
|
client.nick = oldClient.nick
|
|
379
|
+ client.updateNickMaskNoMutex()
|
379
|
380
|
|
380
|
381
|
for channel := range oldClient.channels {
|
381
|
382
|
channel.stateMutex.Lock()
|
382
|
383
|
|
|
384
|
+ client.channels[channel] = true
|
383
|
385
|
client.resumeDetails.SendFakeJoinsFor = append(client.resumeDetails.SendFakeJoinsFor, channel.name)
|
384
|
386
|
|
385
|
387
|
oldModeSet := channel.members[oldClient]
|
|
@@ -387,6 +389,16 @@ func (client *Client) TryResume() {
|
387
|
389
|
channel.members[client] = oldModeSet
|
388
|
390
|
channel.regenerateMembersCache(true)
|
389
|
391
|
|
|
392
|
+ // construct fake modestring if necessary
|
|
393
|
+ oldModes := oldModeSet.String()
|
|
394
|
+ var params []string
|
|
395
|
+ if 0 < len(oldModes) {
|
|
396
|
+ params = []string{channel.name, "+" + oldModes}
|
|
397
|
+ for _ = range oldModes {
|
|
398
|
+ params = append(params, client.nick)
|
|
399
|
+ }
|
|
400
|
+ }
|
|
401
|
+
|
390
|
402
|
// send join for old clients
|
391
|
403
|
for member := range channel.members {
|
392
|
404
|
if member.capabilities.Has(caps.Resume) {
|
|
@@ -399,7 +411,10 @@ func (client *Client) TryResume() {
|
399
|
411
|
member.Send(nil, client.nickMaskString, "JOIN", channel.name)
|
400
|
412
|
}
|
401
|
413
|
|
402
|
|
- //TODO(dan): send priv modes for fake new join
|
|
414
|
+ // send fake modestring if necessary
|
|
415
|
+ if 0 < len(oldModes) {
|
|
416
|
+ member.Send(nil, server.name, "MODE", params...)
|
|
417
|
+ }
|
403
|
418
|
}
|
404
|
419
|
|
405
|
420
|
channel.stateMutex.Unlock()
|
|
@@ -524,7 +539,11 @@ func (client *Client) updateNickMask(nick string) {
|
524
|
539
|
|
525
|
540
|
client.stateMutex.Lock()
|
526
|
541
|
defer client.stateMutex.Unlock()
|
|
542
|
+ client.updateNickMaskNoMutex()
|
|
543
|
+}
|
527
|
544
|
|
|
545
|
+// updateNickMask updates the casefolded nickname and nickmask, not holding any mutexes.
|
|
546
|
+func (client *Client) updateNickMaskNoMutex() {
|
528
|
547
|
if len(client.vhost) > 0 {
|
529
|
548
|
client.hostname = client.vhost
|
530
|
549
|
} else {
|
|
@@ -609,12 +628,14 @@ func (client *Client) destroy(beingResumed bool) {
|
609
|
628
|
// allow destroy() to execute at most once
|
610
|
629
|
if !beingResumed {
|
611
|
630
|
client.stateMutex.Lock()
|
612
|
|
- isDestroyed := client.isDestroyed
|
613
|
|
- client.isDestroyed = true
|
|
631
|
+ }
|
|
632
|
+ isDestroyed := client.isDestroyed
|
|
633
|
+ client.isDestroyed = true
|
|
634
|
+ if !beingResumed {
|
614
|
635
|
client.stateMutex.Unlock()
|
615
|
|
- if isDestroyed {
|
616
|
|
- return
|
617
|
|
- }
|
|
636
|
+ }
|
|
637
|
+ if isDestroyed {
|
|
638
|
+ return
|
618
|
639
|
}
|
619
|
640
|
|
620
|
641
|
if beingResumed {
|