feat(irc): manually re-process announces (#1419)

* fix(releases): add manual processing

* feat(irc): add re-process button to channel msg

* feat(irc): add missing client method

* feat(web): change reprocess icon placement

---------

Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com>
This commit is contained in:
ze0s 2024-03-19 18:23:43 +01:00 committed by GitHub
parent d9fc163655
commit be05ffba73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 306 additions and 18 deletions

View file

@ -719,6 +719,10 @@ func (h *Handler) onMessage(msg ircmsg.Message) {
return
}
func (h *Handler) SendToAnnounceProcessor(channel string, msg string) error {
return h.sendToAnnounceProcessor(channel, msg)
}
// send the msg to announce processor
func (h *Handler) sendToAnnounceProcessor(channel string, msg string) error {
channel = strings.ToLower(channel)

View file

@ -36,6 +36,7 @@ type Service interface {
UpdateNetwork(ctx context.Context, network *domain.IrcNetwork) error
StoreChannel(ctx context.Context, networkID int64, channel *domain.IrcChannel) error
SendCmd(ctx context.Context, req *domain.SendIrcCmdRequest) error
ManualProcessAnnounce(ctx context.Context, req *domain.IRCManualProcessRequest) error
}
type service struct {
@ -408,6 +409,26 @@ func (s *service) GetNetworkByID(ctx context.Context, id int64) (*domain.IrcNetw
return network, nil
}
func (s *service) ManualProcessAnnounce(ctx context.Context, req *domain.IRCManualProcessRequest) error {
network, err := s.repo.GetNetworkByID(ctx, req.NetworkId)
if err != nil {
s.log.Error().Err(err).Msgf("failed to get network: %d", req.NetworkId)
return err
}
handler, ok := s.handlers[network.ID]
if !ok {
return errors.New("could not find irc handler with id: %d", network.ID)
}
err = handler.sendToAnnounceProcessor(req.Channel, req.Message)
if err != nil {
return errors.Wrap(err, "could not send manual announce to processor")
}
return nil
}
func (s *service) ListNetworks(ctx context.Context) ([]domain.IrcNetwork, error) {
networks, err := s.repo.ListNetworks(ctx)
if err != nil {