feat: message reactions + link/image previews
Reactions (full stack): - Wire: MsgReaction peer message (reaction_mid, reaction_emoji) - Store: reactions table (mid, emoji, from_peer), SaveReaction, ReactionsForRoom - Daemon: CmdSendReaction IPC command; EvtReaction IPC event; stored reactions replayed to newly-connected IPC clients alongside history - Web UI: reactions state (mid → emoji → [fromId]); hover a message to reveal a + button; click opens a 6-emoji picker (👍❤️😂😮😢🙏); reaction chips appear below the message with count and tooltip; own reactions highlighted Link/image previews: - URLs in message text rendered as clickable <a> links - Image URLs (.jpg/.jpeg/.png/.gif/.webp/blob:/data:image) rendered as inline thumbnails (max 320×200px) below the link Also scoped push notifications architecture in FUTURE.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -146,6 +146,17 @@ func (m *Mesh) AddPeer(conn *PeerConn) {
|
||||
})
|
||||
}
|
||||
|
||||
// SaveReaction persists a reaction if a store is configured.
|
||||
// Duplicate (mid, emoji, fromPeer) triples are silently dropped.
|
||||
func (m *Mesh) SaveReaction(mid, emoji, fromPeer string) {
|
||||
if m.Store == nil {
|
||||
return
|
||||
}
|
||||
if err := m.Store.SaveReaction(mid, emoji, fromPeer); err != nil {
|
||||
log.Printf("mesh: store reaction %s/%s: %v", mid, emoji, err)
|
||||
}
|
||||
}
|
||||
|
||||
// SaveMessage persists a chat message if a store is configured.
|
||||
// Duplicate mids are silently dropped.
|
||||
func (m *Mesh) SaveMessage(msg *proto.ChatMessage) {
|
||||
|
||||
@@ -307,6 +307,18 @@ func dispatchPeerMessage(msg proto.PeerMessage, from proto.PeerID, m *Mesh) {
|
||||
case proto.MsgHistoryChunk:
|
||||
go m.HandleHistoryChunk(msg.Room, msg.History)
|
||||
|
||||
case proto.MsgReaction:
|
||||
if msg.ReactionMID == "" || msg.ReactionEmoji == "" {
|
||||
return
|
||||
}
|
||||
m.SaveReaction(msg.ReactionMID, msg.ReactionEmoji, string(from))
|
||||
m.emit(proto.IpcMessage{
|
||||
Type: proto.EvtReaction,
|
||||
PeerID: peerIDPtr(from),
|
||||
ReactionMID: msg.ReactionMID,
|
||||
ReactionEmoji: msg.ReactionEmoji,
|
||||
})
|
||||
|
||||
case proto.MsgPing:
|
||||
log.Printf("mesh: ping from %s", from.Short())
|
||||
case proto.MsgPong:
|
||||
|
||||
Reference in New Issue
Block a user