Browse Source

Remove ReadMessage -- it will eventually be replaced by the API's get method

main
Sam 4 years ago
parent
commit
74992fe2c3
  1. 55
      chat.go

55
chat.go

@ -2,8 +2,6 @@ package keybase @@ -2,8 +2,6 @@ package keybase
import (
"bufio"
"encoding/base64"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
@ -15,36 +13,6 @@ import ( @@ -15,36 +13,6 @@ import (
"samhofi.us/x/keybase/types/stellar1"
)
// Returns a string representation of a message id suitable for use in a
// pagination struct
func getID(id uint) string {
var b []byte
switch {
case id < 128:
// 7-bit int
b = make([]byte, 1)
b = []byte{byte(id)}
case id <= 255:
// uint8
b = make([]byte, 2)
b = []byte{204, byte(id)}
case id > 255 && id <= 65535:
// uint16
b = make([]byte, 2)
binary.BigEndian.PutUint16(b, uint16(id))
b = append([]byte{205}, b...)
case id > 65535 && id <= 4294967295:
// uint32
b = make([]byte, 4)
binary.BigEndian.PutUint32(b, uint32(id))
b = append([]byte{206}, b...)
}
return base64.StdEncoding.EncodeToString(b)
}
// Creates a string of a json-encoded channel to pass to keybase chat api-listen --filter-channel
func createFilterString(channel chat1.ChatChannel) string {
if channel.Name == "" {
@ -537,29 +505,6 @@ func (k *Keybase) ReadConversationPrevious(conv chat1.ConvIDStr, previous []byte @@ -537,29 +505,6 @@ func (k *Keybase) ReadConversationPrevious(conv chat1.ConvIDStr, previous []byte
return k.Read(opts)
}
// ReadMessage fetches the chat message with the specified message id from a conversation.
func (c Chat) ReadMessage(messageID int) (*ChatAPI, error) {
m := ChatAPI{
Params: &params{},
}
m.Params.Options = options{
Pagination: &pagination{},
}
m.Method = "read"
m.Params.Options.Channel = &c.Channel
m.Params.Options.Pagination.Num = 1
m.Params.Options.Pagination.Previous = getID(uint(messageID - 1))
r, err := chatAPIOut(c.keybase, m)
if err != nil {
return &r, err
}
r.keybase = *c.keybase
return &r, nil
}
// UploadToChannel attaches a file to a channel
// The filename must be an absolute path
func (k *Keybase) UploadToChannel(channel chat1.ChatChannel, title string, filename string) (chat1.SendRes, error) {

Loading…
Cancel
Save