mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
Feature: Support multiline irc parsing (#39)
* feat: initial multiline support * refactor: handle multiple indexers per network * wip: setup indexer * build: add docker compose for testing * chore: remove temp mock indexers * chore: update deps * refactor: update and store network handler * build: update test compose * chore: minor cleanup
This commit is contained in:
parent
506cef6f0f
commit
c4d580eb03
17 changed files with 1100 additions and 1042 deletions
|
@ -15,7 +15,8 @@ type ircService interface {
|
|||
ListNetworks(ctx context.Context) ([]domain.IrcNetwork, error)
|
||||
DeleteNetwork(ctx context.Context, id int64) error
|
||||
GetNetworkByID(id int64) (*domain.IrcNetwork, error)
|
||||
StoreNetwork(network *domain.IrcNetwork) error
|
||||
StoreNetwork(ctx context.Context, network *domain.IrcNetwork) error
|
||||
UpdateNetwork(ctx context.Context, network *domain.IrcNetwork) error
|
||||
StoreChannel(networkID int64, channel *domain.IrcChannel) error
|
||||
StopNetwork(name string) error
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ func newIrcHandler(encoder encoder, service ircService) *ircHandler {
|
|||
func (h ircHandler) Routes(r chi.Router) {
|
||||
r.Get("/", h.listNetworks)
|
||||
r.Post("/", h.storeNetwork)
|
||||
r.Put("/network/{networkID}", h.storeNetwork)
|
||||
r.Put("/network/{networkID}", h.updateNetwork)
|
||||
r.Post("/network/{networkID}/channel", h.storeChannel)
|
||||
r.Get("/network/{networkID}/stop", h.stopNetwork)
|
||||
r.Get("/network/{networkID}", h.getNetworkByID)
|
||||
|
@ -79,7 +80,27 @@ func (h ircHandler) storeNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
err := h.service.StoreNetwork(&data)
|
||||
err := h.service.StoreNetwork(ctx, &data)
|
||||
if err != nil {
|
||||
//
|
||||
h.encoder.StatusResponse(ctx, w, nil, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, nil, http.StatusCreated)
|
||||
}
|
||||
|
||||
func (h ircHandler) updateNetwork(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
ctx = r.Context()
|
||||
data domain.IrcNetwork
|
||||
)
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&data); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err := h.service.UpdateNetwork(ctx, &data)
|
||||
if err != nil {
|
||||
//
|
||||
h.encoder.StatusResponse(ctx, w, nil, http.StatusBadRequest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue