~gjabell/irc-ntfy

86c40711af7cd9309df2d8a919418ac579833d01 — Galen Abell 2 months ago 25e574e
Update READ to MARKREAD
1 files changed, 6 insertions(+), 6 deletions(-)

M main.go
M main.go => main.go +6 -6
@@ 34,7 34,7 @@ func (f *csvMap) Set(value string) error {
	return nil
}

var readReceiptCaps = []string{"soju.im/read", "draft/read-marker"}
var readReceiptCaps = []string{"draft/read-marker"}

type ReadReceiptStore struct {
	rw       *sync.RWMutex


@@ 249,13 249,13 @@ func (c *IRCClient) onPrivMsg(conn *irc.Conn, line *irc.Line) {
		}

		// Mark the message as read so it doesn't ping other clients.
		conn.Read(channel, line.Time)
		conn.MarkRead(channel, line.Time)
	}()
}

func (c *IRCClient) onRead(conn *irc.Conn, line *irc.Line) {
	if len(line.Args) < 2 {
		log.Println("Skipping READ with improper channel and msg")
		log.Println("Skipping MARKREAD with improper channel and msg")
		return
	}



@@ 267,12 267,12 @@ func (c *IRCClient) onRead(conn *irc.Conn, line *irc.Line) {
	readTimestamp := strings.TrimPrefix(line.Args[1], "timestamp=")
	timestamp, err := time.Parse(irc.ServerTimeLayout, readTimestamp)
	if err != nil {
		log.Println("Skipping invalid READ timestamp for " + channel)
		log.Println("Skipping invalid MARKREAD timestamp for " + channel)
		return
	}
	timestamp = timestamp.UTC()

	log.Printf("Storing READ timestamp for %s: %s\n", channel,
	log.Printf("Storing MARKREAD timestamp for %s: %s\n", channel,
		timestamp.String())
	c.readReceipts.Put(channel, timestamp)
}


@@ 283,7 283,7 @@ func (c *IRCClient) onDisconnect(conn *irc.Conn, line *irc.Line) {

func (c *IRCClient) Run() error {
	c.conn.HandleFunc(irc.PRIVMSG, c.onPrivMsg)
	c.conn.HandleFunc(irc.READ, c.onRead)
	c.conn.HandleFunc(irc.MARKREAD, c.onRead)
	c.conn.HandleFunc(irc.DISCONNECTED, c.onDisconnect)

	if err := c.conn.Connect(); err != nil {