mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 03:02:48 +01:00
Merge pull request #1415 from slingamn/issue1409_invite_history.1
fix #1409
This commit is contained in:
commit
5edfcced0a
@ -1507,24 +1507,33 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf
|
|||||||
invitee.Invite(chcfname, createdAt)
|
invitee.Invite(chcfname, createdAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
details := inviter.Details()
|
||||||
|
tDetails := invitee.Details()
|
||||||
|
tnick := invitee.Nick()
|
||||||
|
message := utils.MakeMessage("")
|
||||||
|
item := history.Item{
|
||||||
|
Type: history.Invite,
|
||||||
|
Message: message,
|
||||||
|
Params: [1]string{chname},
|
||||||
|
}
|
||||||
|
|
||||||
for _, member := range channel.Members() {
|
for _, member := range channel.Members() {
|
||||||
if member == inviter || member == invitee || !channel.ClientIsAtLeast(member, modes.Halfop) {
|
if member == inviter || member == invitee || !channel.ClientIsAtLeast(member, modes.Halfop) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, session := range member.Sessions() {
|
for _, session := range member.Sessions() {
|
||||||
if session.capabilities.Has(caps.InviteNotify) {
|
if session.capabilities.Has(caps.InviteNotify) {
|
||||||
session.Send(nil, inviter.NickMaskString(), "INVITE", invitee.Nick(), chname)
|
session.sendFromClientInternal(false, message.Time, message.Msgid, details.nickMask, details.accountName, nil, "INVITE", tnick, chname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cnick := inviter.Nick()
|
rb.Add(nil, inviter.server.name, RPL_INVITING, details.nick, tnick, chname)
|
||||||
tnick := invitee.Nick()
|
invitee.sendFromClientInternal(false, message.Time, message.Msgid, details.nickMask, details.accountName, nil, "INVITE", tnick, chname)
|
||||||
rb.Add(nil, inviter.server.name, RPL_INVITING, cnick, tnick, chname)
|
|
||||||
invitee.Send(nil, inviter.NickMaskString(), "INVITE", tnick, chname)
|
|
||||||
if away, awayMessage := invitee.Away(); away {
|
if away, awayMessage := invitee.Away(); away {
|
||||||
rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, awayMessage)
|
rb.Add(nil, inviter.server.name, RPL_AWAY, details.nick, tnick, awayMessage)
|
||||||
}
|
}
|
||||||
|
inviter.addHistoryItem(invitee, item, &details, &tDetails, channel.server.Config())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uninvite rescinds a channel invitation, if the inviter can do so.
|
// Uninvite rescinds a channel invitation, if the inviter can do so.
|
||||||
|
@ -1055,6 +1055,13 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I
|
|||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
var command string
|
var command string
|
||||||
switch item.Type {
|
switch item.Type {
|
||||||
|
case history.Invite:
|
||||||
|
if hasEventPlayback {
|
||||||
|
rb.AddFromClient(item.Message.Time, item.Message.Msgid, item.Nick, item.AccountName, nil, "INVITE", item.Params[0])
|
||||||
|
} else {
|
||||||
|
rb.AddFromClient(item.Message.Time, utils.MungeSecretToken(item.Message.Msgid), histservService.prefix, "*", nil, "PRIVMSG", fmt.Sprintf(client.t("%[1]s invited you to channel %[2]s"), stripMaskFromNick(item.Nick), item.Params[0]))
|
||||||
|
}
|
||||||
|
continue
|
||||||
case history.Privmsg:
|
case history.Privmsg:
|
||||||
command = "PRIVMSG"
|
command = "PRIVMSG"
|
||||||
case history.Notice:
|
case history.Notice:
|
||||||
@ -1088,7 +1095,7 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I
|
|||||||
|
|
||||||
rb.EndNestedBatch(batchID)
|
rb.EndNestedBatch(batchID)
|
||||||
if !complete {
|
if !complete {
|
||||||
rb.Add(nil, "HistServ", "NOTICE", nick, client.t("Some additional message history may have been lost"))
|
rb.Add(nil, histservService.prefix, "NOTICE", nick, client.t("Some additional message history may have been lost"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1862,6 +1869,34 @@ func (client *Client) historyStatus(config *Config) (status HistoryStatus, targe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *Client) addHistoryItem(target *Client, item history.Item, details, tDetails *ClientDetails, config *Config) (err error) {
|
||||||
|
if !itemIsStorable(&item, config) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
item.Nick = details.nickMask
|
||||||
|
item.AccountName = details.accountName
|
||||||
|
targetedItem := item
|
||||||
|
targetedItem.Params[0] = tDetails.nick
|
||||||
|
|
||||||
|
cStatus, _ := client.historyStatus(config)
|
||||||
|
tStatus, _ := target.historyStatus(config)
|
||||||
|
// add to ephemeral history
|
||||||
|
if cStatus == HistoryEphemeral {
|
||||||
|
targetedItem.CfCorrespondent = tDetails.nickCasefolded
|
||||||
|
client.history.Add(targetedItem)
|
||||||
|
}
|
||||||
|
if tStatus == HistoryEphemeral && client != target {
|
||||||
|
item.CfCorrespondent = details.nickCasefolded
|
||||||
|
target.history.Add(item)
|
||||||
|
}
|
||||||
|
if cStatus == HistoryPersistent || tStatus == HistoryPersistent {
|
||||||
|
targetedItem.CfCorrespondent = ""
|
||||||
|
client.server.historyDB.AddDirectMessage(details.nickCasefolded, details.account, tDetails.nickCasefolded, tDetails.account, targetedItem)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (client *Client) handleRegisterTimeout() {
|
func (client *Client) handleRegisterTimeout() {
|
||||||
client.Quit(fmt.Sprintf("Registration timeout: %v", RegisterTimeout), nil)
|
client.Quit(fmt.Sprintf("Registration timeout: %v", RegisterTimeout), nil)
|
||||||
client.destroy(nil)
|
client.destroy(nil)
|
||||||
|
@ -2143,6 +2143,10 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !allowedPlusR {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
if !config.History.Enabled {
|
if !config.History.Enabled {
|
||||||
return
|
return
|
||||||
@ -2150,30 +2154,9 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
|
|||||||
item := history.Item{
|
item := history.Item{
|
||||||
Type: histType,
|
Type: histType,
|
||||||
Message: message,
|
Message: message,
|
||||||
Nick: nickMaskString,
|
|
||||||
AccountName: accountName,
|
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
}
|
}
|
||||||
if !itemIsStorable(&item, config) || !allowedPlusR {
|
client.addHistoryItem(user, item, &details, &tDetails, config)
|
||||||
return
|
|
||||||
}
|
|
||||||
targetedItem := item
|
|
||||||
targetedItem.Params[0] = tnick
|
|
||||||
cStatus, _ := client.historyStatus(config)
|
|
||||||
tStatus, _ := user.historyStatus(config)
|
|
||||||
// add to ephemeral history
|
|
||||||
if cStatus == HistoryEphemeral {
|
|
||||||
targetedItem.CfCorrespondent = tDetails.nickCasefolded
|
|
||||||
client.history.Add(targetedItem)
|
|
||||||
}
|
|
||||||
if tStatus == HistoryEphemeral && client != user {
|
|
||||||
item.CfCorrespondent = details.nickCasefolded
|
|
||||||
user.history.Add(item)
|
|
||||||
}
|
|
||||||
if cStatus == HistoryPersistent || tStatus == HistoryPersistent {
|
|
||||||
targetedItem.CfCorrespondent = ""
|
|
||||||
server.historyDB.AddDirectMessage(details.nickCasefolded, details.account, tDetails.nickCasefolded, tDetails.account, targetedItem)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ const (
|
|||||||
Tagmsg
|
Tagmsg
|
||||||
Nick
|
Nick
|
||||||
Topic
|
Topic
|
||||||
|
Invite
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
Reference in New Issue
Block a user