Add 'new channel' and 'update channel' events
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
199514857a
commit
1144c615da
|
@ -58,6 +58,16 @@ type channelSetting struct {
|
|||
ChannelType string
|
||||
}
|
||||
|
||||
type channelMessage struct {
|
||||
Version int `json:"version"`
|
||||
Channel microsub.Channel `json:"channel"`
|
||||
}
|
||||
|
||||
type newItemMessage struct {
|
||||
Item microsub.Item `json:"item"`
|
||||
Channel string `json:"channel"`
|
||||
}
|
||||
|
||||
// Debug interface for easy of use in other packages
|
||||
type Debug interface {
|
||||
Debug()
|
||||
|
@ -210,6 +220,8 @@ func (b *memoryBackend) ChannelsCreate(name string) (microsub.Channel, error) {
|
|||
|
||||
updateChannelInRedis(conn, channel.UID, DefaultPrio)
|
||||
|
||||
b.broker.Notifier <- sse.Message{Event: "new channel", Object: channelMessage{1, channel}}
|
||||
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
|
@ -228,6 +240,8 @@ func (b *memoryBackend) ChannelsUpdate(uid, name string) (microsub.Channel, erro
|
|||
b.Channels[uid] = c
|
||||
b.lock.Unlock()
|
||||
|
||||
b.broker.Notifier <- sse.Message{Event: "update channel", Object: channelMessage{1, c}}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
|
@ -673,11 +687,6 @@ func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) error
|
|||
timelineBackend := b.getTimeline(channel)
|
||||
added, err := timelineBackend.AddItem(item)
|
||||
|
||||
type newItemMessage struct {
|
||||
Item microsub.Item `json:"item"`
|
||||
Channel string `json:"channel"`
|
||||
}
|
||||
|
||||
// Sent message to Server-Sent-Events
|
||||
if added {
|
||||
b.broker.Notifier <- sse.Message{Event: "new item", Object: newItemMessage{item, channel}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user