mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
miscellaneous review fixes
This commit is contained in:
parent
82732d5b5d
commit
8f4c14c783
@ -871,8 +871,12 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I
|
||||
if allowTags {
|
||||
tags = item.Tags
|
||||
}
|
||||
// XXX: Params[0] is the message target. if the source of this message is an in-memory
|
||||
// buffer, then it's "" for an incoming message and the recipient's nick for an outgoing
|
||||
// message. if the source of the message is mysql, then mysql only sees one copy of the
|
||||
// message, and it's the version with the recipient's nick filled in. so this is an
|
||||
// incoming message if Params[0] (the recipient's nick) equals the client's nick:
|
||||
if item.Params[0] == "" || item.Params[0] == nick {
|
||||
// this message was sent *to* the client from another nick
|
||||
rb.AddSplitMessageFromClient(item.Nick, item.AccountName, tags, command, nick, item.Message)
|
||||
} else {
|
||||
// this message was sent *from* the client to another nick; the target is item.Params[0]
|
||||
@ -1237,9 +1241,9 @@ func (client *Client) destroy(session *Session) {
|
||||
Message: splitQuitMessage,
|
||||
}
|
||||
var channels []*Channel
|
||||
// use a defer here to avoid writing to mysql while holding the destroy semaphore:
|
||||
defer func() {
|
||||
for _, channel := range channels {
|
||||
// TODO it's dangerous to write to mysql while holding the destroy semaphore
|
||||
channel.AddHistoryItem(quitItem)
|
||||
}
|
||||
}()
|
||||
|
@ -1914,7 +1914,7 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
|
||||
var deliverySessions []*Session
|
||||
// restrict messages appropriately when +R is set
|
||||
// intentionally make the sending user think the message went through fine
|
||||
allowedPlusR := !user.HasMode(modes.RegisteredOnly) || details.account != ""
|
||||
allowedPlusR := details.account != "" || !user.HasMode(modes.RegisteredOnly)
|
||||
if allowedPlusR {
|
||||
deliverySessions = append(deliverySessions, user.Sessions()...)
|
||||
}
|
||||
|
@ -42,9 +42,12 @@ type Item struct {
|
||||
// this is the uncasefolded account name, if there's no account it should be set to "*"
|
||||
AccountName string
|
||||
// for non-privmsg items, we may stuff some other data in here
|
||||
Message utils.SplitMessage
|
||||
Tags map[string]string
|
||||
Params [1]string
|
||||
Message utils.SplitMessage
|
||||
Tags map[string]string
|
||||
Params [1]string
|
||||
// for a DM, this is the casefolded nickname of the other party (whether this is
|
||||
// an incoming or outgoing message). this lets us emulate the "query buffer" functionality
|
||||
// required by CHATHISTORY:
|
||||
CfCorrespondent string
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -197,7 +196,7 @@ func (mysql *MySQL) doCleanup(age time.Duration) (count int, err error) {
|
||||
if i != 0 {
|
||||
inBuf.WriteRune(',')
|
||||
}
|
||||
inBuf.WriteString(strconv.FormatInt(int64(id), 10))
|
||||
fmt.Fprintf(&inBuf, "%d", id)
|
||||
}
|
||||
inBuf.WriteRune(')')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user