mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-04 19:57:07 +00:00
Support reply ID accounting for SFS uploads
This commit is contained in:
parent
eee277e36e
commit
7d9f20d007
2 changed files with 27 additions and 3 deletions
|
|
@ -221,6 +221,12 @@ type EntityTime struct {
|
|||
ResultSet *stanza.ResultSet `xml:"set,omitempty"`
|
||||
}
|
||||
|
||||
// AttachTo is from XEP-0367
|
||||
type AttachTo struct {
|
||||
XMLName xml.Name `xml:"urn:xmpp:message-attaching:1 attach-to"`
|
||||
Id string `xml:"id,attr"`
|
||||
}
|
||||
|
||||
// Namespace is a namespace!
|
||||
func (c PresenceNickExtension) Namespace() string {
|
||||
return c.XMLName.Space
|
||||
|
|
@ -301,6 +307,11 @@ func (ClientMessage) Name() string {
|
|||
return "message"
|
||||
}
|
||||
|
||||
// Namespace is a namespace!
|
||||
func (c AttachTo) Namespace() string {
|
||||
return c.XMLName.Space
|
||||
}
|
||||
|
||||
// NewReplyFallback initializes a fallback range
|
||||
func NewReplyFallback(start uint64, end uint64) Fallback {
|
||||
return Fallback{
|
||||
|
|
@ -386,4 +397,10 @@ func init() {
|
|||
"urn:xmpp:time",
|
||||
"time",
|
||||
}, EntityTime{})
|
||||
|
||||
// attach-to
|
||||
stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{
|
||||
"urn:xmpp:message-attaching:1",
|
||||
"attach-to",
|
||||
}, AttachTo{})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,12 +149,15 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
|
|||
var reply extensions.Reply
|
||||
var fallback extensions.Fallback
|
||||
var replace extensions.Replace
|
||||
var attachTo extensions.AttachTo
|
||||
msg.Get(&reply)
|
||||
msg.Get(&fallback)
|
||||
msg.Get(&replace)
|
||||
msg.Get(&attachTo)
|
||||
log.Debugf("reply: %#v", reply)
|
||||
log.Debugf("fallback: %#v", fallback)
|
||||
log.Debugf("replace: %#v", replace)
|
||||
log.Debugf("attachTo: %#v", attachTo)
|
||||
|
||||
var replyId int64
|
||||
var err error
|
||||
|
|
@ -230,12 +233,16 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
|
|||
} */
|
||||
session.AddToEditOutbox(replace.Id, resource)
|
||||
} else {
|
||||
err = gateway.IdsDB.Set(session.Session.Login, bare, toID, tgMessageId, msg.Id)
|
||||
messageId := msg.Id
|
||||
if attachTo.Id != "" {
|
||||
messageId = attachTo.Id
|
||||
}
|
||||
err = gateway.IdsDB.Set(session.Session.Login, bare, toID, tgMessageId, messageId)
|
||||
if err == nil {
|
||||
// session.AddToOutbox(msg.Id, resource)
|
||||
session.UpdateLastChatMessageId(toID, msg.Id)
|
||||
session.UpdateLastChatMessageId(toID, messageId)
|
||||
} else {
|
||||
log.Errorf("Failed to save ids %v/%v %v", toID, tgMessageId, msg.Id)
|
||||
log.Errorf("Failed to save ids %v/%v %v", toID, tgMessageId, messageId)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue