package handler

import (
	"net/http"

	"haixun-backend/internal/handler/static"
	threads_account "haixun-backend/internal/handler/threads_account"
	"haixun-backend/internal/svc"

	"github.com/zeromicro/go-zero/rest"
)

// RegisterExtraHandlers mounts routes that are not generated by goctl.
func RegisterExtraHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		[]rest.Route{
			{
				Method:  http.MethodGet,
				Path:    "/downloads/haixun-threads-sync.zip",
				Handler: static.ExtensionDownloadHandler(),
			},
		},
		rest.WithPrefix("/api/v1"),
	)

	// Legacy Meta redirect URI (deploy/.env.dev 曾誤設為 /api/threads/oauth/callback)。
	server.AddRoutes(
		[]rest.Route{
			{
				Method:  http.MethodGet,
				Path:    "/oauth/callback",
				Handler: threads_account.ThreadsOauthCallbackHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/threads"),
	)
}
