Add MUC history limit (maxstanzas only)
This commit is contained in:
parent
e8bde73164
commit
b68c07025d
|
@ -304,7 +304,7 @@ func (c *Client) ProcessStatusUpdate(chatID int64, status string, show string, o
|
||||||
}
|
}
|
||||||
|
|
||||||
// JoinMUC saves MUC join fact and sends initialization data
|
// JoinMUC saves MUC join fact and sends initialization data
|
||||||
func (c *Client) JoinMUC(chatId int64, resource string) {
|
func (c *Client) JoinMUC(chatId int64, resource string, limit int32) {
|
||||||
// save the nickname in this MUC, also as a marker of join
|
// save the nickname in this MUC, also as a marker of join
|
||||||
c.locks.mucResourcesLock.Lock()
|
c.locks.mucResourcesLock.Lock()
|
||||||
oldMap, ok := c.mucResources[chatId]
|
oldMap, ok := c.mucResources[chatId]
|
||||||
|
@ -324,7 +324,7 @@ func (c *Client) JoinMUC(chatId int64, resource string) {
|
||||||
|
|
||||||
c.sendMUCStatuses(chatId)
|
c.sendMUCStatuses(chatId)
|
||||||
|
|
||||||
messages, err := c.getNLastMessages(chatId, 20)
|
messages, err := c.getNLastMessages(chatId, limit)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
c.sendMessagesReverse(chatId, messages, false, c.jid+"/"+resource)
|
c.sendMessagesReverse(chatId, messages, false, c.jid+"/"+resource)
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ func HandlePresence(s xmpp.Sender, p stanza.Packet) {
|
||||||
var mucExt stanza.MucPresence
|
var mucExt stanza.MucPresence
|
||||||
prs.Get(&mucExt)
|
prs.Get(&mucExt)
|
||||||
if mucExt.XMLName.Space != "" {
|
if mucExt.XMLName.Space != "" {
|
||||||
handleMUCPresence(s, prs)
|
handleMUCPresence(s, prs, mucExt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMUCPresence(s xmpp.Sender, p stanza.Presence) {
|
func handleMUCPresence(s xmpp.Sender, p stanza.Presence, mucExt stanza.MucPresence) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"type": p.Type,
|
"type": p.Type,
|
||||||
"from": p.From,
|
"from": p.From,
|
||||||
|
@ -458,7 +458,11 @@ func handleMUCPresence(s xmpp.Sender, p stanza.Presence) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
session.JoinMUC(chatId, fromResource)
|
limit, ok := mucExt.History.MaxStanzas.Get()
|
||||||
|
if !ok {
|
||||||
|
limit = 20
|
||||||
|
}
|
||||||
|
session.JoinMUC(chatId, fromResource, int32(limit))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue