]> git.r.bdr.sh - rbdr/mobius/commitdiff
Implement reply quoting
authorJeff Halter <redacted>
Thu, 2 Jun 2022 22:20:21 +0000 (15:20 -0700)
committerJeff Halter <redacted>
Thu, 2 Jun 2022 22:20:21 +0000 (15:20 -0700)
hotline/field.go
hotline/transaction_handlers.go

index 26012afefcb6e61d17064e5d0d5d5a169c79f348..ed009f480eced064145bcf5b8cbfdb721dada288 100644 (file)
@@ -38,7 +38,7 @@ const fieldFileComment = 210
 const fieldFileNewName = 211
 const fieldFileNewPath = 212
 const fieldFileType = 213
-const fieldQuotingMsg = 214 // Defined but unused in the Hotline Protocol spec
+const fieldQuotingMsg = 214
 const fieldAutomaticResponse = 215
 const fieldFolderItemCount = 220
 const fieldUsernameWithInfo = 300
index 745cb409d8ffd0c28b273350116161f26d633cce..ea2409a7e996aa18d1ce1ab076629ff436fa0095 100644 (file)
@@ -366,21 +366,25 @@ func HandleChatSend(cc *ClientConn, t *Transaction) (res []Transaction, err erro
 func HandleSendInstantMsg(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
        msg := t.GetField(fieldData)
        ID := t.GetField(fieldUserID)
-       // TODO: Implement reply quoting
-       // options := transaction.GetField(hotline.fieldOptions)
 
-       res = append(res,
-               *NewTransaction(
-                       tranServerMsg,
-                       &ID.Data,
-                       NewField(fieldData, msg.Data),
-                       NewField(fieldUserName, cc.UserName),
-                       NewField(fieldUserID, *cc.ID),
-                       NewField(fieldOptions, []byte{0, 1}),
-               ),
+       reply := *NewTransaction(
+               tranServerMsg,
+               &ID.Data,
+               NewField(fieldData, msg.Data),
+               NewField(fieldUserName, cc.UserName),
+               NewField(fieldUserID, *cc.ID),
+               NewField(fieldOptions, []byte{0, 1}),
        )
-       id, _ := byteToInt(ID.Data)
 
+       // Later versions of Hotline include the original message in the fieldQuotingMsg field so
+       //  the receiving client can display both the received message and what it is in reply to
+       if t.GetField(fieldQuotingMsg).Data != nil {
+               reply.Fields = append(reply.Fields, NewField(fieldQuotingMsg, t.GetField(fieldQuotingMsg).Data))
+       }
+
+       res = append(res, reply)
+
+       id, _ := byteToInt(ID.Data)
        otherClient := cc.Server.Clients[uint16(id)]
        if otherClient == nil {
                return res, errors.New("ohno")