|
@@ -350,32 +350,36 @@ func (channel *Channel) IsEmpty() bool {
|
350
|
350
|
}
|
351
|
351
|
|
352
|
352
|
// Join joins the given client to this channel (if they can be joined).
|
353
|
|
-//TODO(dan): /SAJOIN and maybe a ForceJoin function?
|
354
|
|
-func (channel *Channel) Join(client *Client, key string, rb *ResponseBuffer) {
|
|
353
|
+func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *ResponseBuffer) {
|
355
|
354
|
if channel.hasClient(client) {
|
356
|
355
|
// already joined, no message needs to be sent
|
357
|
356
|
return
|
358
|
357
|
}
|
359
|
358
|
|
360
|
|
- chname := channel.Name()
|
|
359
|
+ channel.stateMutex.RLock()
|
|
360
|
+ chname := channel.name
|
|
361
|
+ founder := channel.registeredFounder
|
|
362
|
+ channel.stateMutex.RUnlock()
|
|
363
|
+ account := client.Account()
|
|
364
|
+ hasPrivs := isSajoin || (founder != "" && founder == account)
|
361
|
365
|
|
362
|
|
- if channel.IsFull() {
|
|
366
|
+ if !hasPrivs && channel.IsFull() {
|
363
|
367
|
rb.Add(nil, client.server.name, ERR_CHANNELISFULL, chname, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "l"))
|
364
|
368
|
return
|
365
|
369
|
}
|
366
|
370
|
|
367
|
|
- if !channel.CheckKey(key) {
|
|
371
|
+ if !hasPrivs && !channel.CheckKey(key) {
|
368
|
372
|
rb.Add(nil, client.server.name, ERR_BADCHANNELKEY, chname, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "k"))
|
369
|
373
|
return
|
370
|
374
|
}
|
371
|
375
|
|
372
|
376
|
isInvited := channel.lists[modes.InviteMask].Match(client.nickMaskCasefolded)
|
373
|
|
- if channel.flags.HasMode(modes.InviteOnly) && !isInvited {
|
|
377
|
+ if !hasPrivs && channel.flags.HasMode(modes.InviteOnly) && !isInvited {
|
374
|
378
|
rb.Add(nil, client.server.name, ERR_INVITEONLYCHAN, chname, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "i"))
|
375
|
379
|
return
|
376
|
380
|
}
|
377
|
381
|
|
378
|
|
- if channel.lists[modes.BanMask].Match(client.nickMaskCasefolded) &&
|
|
382
|
+ if !hasPrivs && channel.lists[modes.BanMask].Match(client.nickMaskCasefolded) &&
|
379
|
383
|
!isInvited &&
|
380
|
384
|
!channel.lists[modes.ExceptMask].Match(client.nickMaskCasefolded) {
|
381
|
385
|
rb.Add(nil, client.server.name, ERR_BANNEDFROMCHAN, chname, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "b"))
|
|
@@ -389,7 +393,6 @@ func (channel *Channel) Join(client *Client, key string, rb *ResponseBuffer) {
|
389
|
393
|
defer channel.joinPartMutex.Unlock()
|
390
|
394
|
|
391
|
395
|
func() {
|
392
|
|
- account := client.Account()
|
393
|
396
|
channel.stateMutex.Lock()
|
394
|
397
|
defer channel.stateMutex.Unlock()
|
395
|
398
|
|
|
@@ -779,7 +782,7 @@ func (channel *Channel) Kick(client *Client, target *Client, comment string, rb
|
779
|
782
|
return
|
780
|
783
|
}
|
781
|
784
|
if !channel.ClientHasPrivsOver(client, target) {
|
782
|
|
- rb.Add(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, client.t("You're not a channel operator"))
|
|
785
|
+ rb.Add(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, client.t("You don't have enough channel privileges"))
|
783
|
786
|
return
|
784
|
787
|
}
|
785
|
788
|
|