mirror of
https://github.com/idanoo/autobrr
synced 2025-07-25 17:59:14 +00:00
fix(irc): view channel history (#987)
fix(irc): irc monitor channels * base64 sse stream key
This commit is contained in:
parent
2af0021ce6
commit
ecc84f5f2d
3 changed files with 11 additions and 4 deletions
|
@ -547,7 +547,9 @@ func (h *Handler) onNick(msg ircmsg.Message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) publishSSEMsg(msg domain.IrcMessage) {
|
func (h *Handler) publishSSEMsg(msg domain.IrcMessage) {
|
||||||
h.sse.Publish(fmt.Sprintf("%d%s", h.network.ID, strings.TrimPrefix(msg.Channel, "#")), &sse.Event{
|
key := genSSEKey(h.network.ID, msg.Channel)
|
||||||
|
|
||||||
|
h.sse.Publish(key, &sse.Event{
|
||||||
Data: msg.Bytes(),
|
Data: msg.Bytes(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ package irc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -638,7 +639,7 @@ func (s *service) SendCmd(ctx context.Context, req *domain.SendIrcCmdRequest) er
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) createSSEStream(networkId int64, channel string) {
|
func (s *service) createSSEStream(networkId int64, channel string) {
|
||||||
key := fmt.Sprintf("%d%s", networkId, strings.TrimPrefix(channel, "#"))
|
key := genSSEKey(networkId, channel)
|
||||||
|
|
||||||
s.sse.CreateStreamWithOpts(key, sse.StreamOpts{
|
s.sse.CreateStreamWithOpts(key, sse.StreamOpts{
|
||||||
MaxEntries: sseMaxEntries,
|
MaxEntries: sseMaxEntries,
|
||||||
|
@ -647,7 +648,11 @@ func (s *service) createSSEStream(networkId int64, channel string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) removeSSEStream(networkId int64, channel string) {
|
func (s *service) removeSSEStream(networkId int64, channel string) {
|
||||||
key := fmt.Sprintf("%d%s", networkId, strings.TrimPrefix(channel, "#"))
|
key := genSSEKey(networkId, channel)
|
||||||
|
|
||||||
s.sse.RemoveStream(key)
|
s.sse.RemoveStream(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func genSSEKey(networkId int64, channel string) string {
|
||||||
|
return base64.URLEncoding.EncodeToString([]byte(fmt.Sprintf("%d%s", networkId, strings.ToLower(channel))))
|
||||||
|
}
|
||||||
|
|
|
@ -629,7 +629,7 @@ export const Events = ({ network, channel }: EventsProps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const key = `${network.id}${channel.replace("#", "")}`;
|
const key = btoa(`${network.id}${channel.toLowerCase()}`);
|
||||||
const es = APIClient.irc.events(key);
|
const es = APIClient.irc.events(key);
|
||||||
|
|
||||||
es.onmessage = (event) => {
|
es.onmessage = (event) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue