The code and data behind xeiaso.net
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/xesite: rip out legacy mi integration

Signed-off-by: Xe Iaso <me@xeiaso.net>

Xe Iaso 5d37f3b5 f1118cbd

-77
-2
cmd/xesite/main.go
··· 28 28 githubSecret = flag.String("github-secret", "", "GitHub secret to use for webhooks") 29 29 internalAPIBind = flag.String("internal-api-bind", ":3001", "Port to listen on for the internal API") 30 30 mimiAnnounceURL = flag.String("mimi-announce-url", "", "URL to use for the mimi announce service") 31 - miToken = flag.String("mi-token", "", "Token to use for the mi API") 32 31 patreonSaasProxyURL = flag.String("patreon-saasproxy-url", "http://xesite-patreon-saasproxy.flycast", "URL to use for the patreon saasproxy") 33 32 siteURL = flag.String("site-url", "https://xeiaso.net/", "URL to use for the site") 34 33 ) ··· 65 64 Development: *devel, 66 65 PatreonClient: pc, 67 66 DataDir: *dataDir, 68 - MiToken: *miToken, 69 67 MimiAnnounceURL: *mimiAnnounceURL, 70 68 }) 71 69 if err != nil {
-22
internal/lume/lume.go
··· 26 26 "tailscale.com/metrics" 27 27 "xeiaso.net/v4/internal/config" 28 28 "xeiaso.net/v4/internal/jsonfeed" 29 - "xeiaso.net/v4/internal/mi" 30 29 "xeiaso.net/v4/pb/external/mimi/announce" 31 30 "xeiaso.net/v4/pb/external/protofeed" 32 31 ) ··· 71 70 opt *Options 72 71 conf *config.Config 73 72 74 - miClient *mi.Client 75 73 mimiClient announce.Announce 76 74 77 75 fs fs.FS ··· 131 129 URL string 132 130 PatreonClient *patreon.Client 133 131 DataDir string 134 - MiToken string 135 132 MimiAnnounceURL string 136 133 } 137 134 ··· 209 206 siteCommit = ref.Hash().String() 210 207 } 211 208 212 - if o.MiToken != "" { 213 - fs.miClient = mi.New(o.MiToken, "xeiaso.net/v4/internal/lume "+os.Args[0]) 214 - slog.Debug("mi integration enabled") 215 - } 216 - 217 209 if o.MimiAnnounceURL != "" { 218 210 mimiClient := announce.NewAnnounceProtobufClient(o.MimiAnnounceURL, &http.Client{}) 219 211 fs.mimiClient = mimiClient ··· 231 223 return nil, err 232 224 } 233 225 234 - if fs.miClient != nil { 235 - go func() { 236 - if err := fs.miClient.Refresh(); err != nil { 237 - slog.Error("failed to refresh mi", "err", err) 238 - } 239 - }() 240 - } 241 226 go fs.mimiRefresh() 242 227 fs.lastBuildTime = time.Now() 243 228 ··· 303 288 return err 304 289 } 305 290 306 - if f.miClient != nil { 307 - go func() { 308 - if err := f.miClient.Refresh(); err != nil { 309 - slog.Error("failed to refresh mi", "err", err) 310 - } 311 - }() 312 - } 313 291 go f.mimiRefresh() 314 292 315 293 return nil
-53
internal/mi/mi.go
··· 1 - package mi 2 - 3 - import ( 4 - "errors" 5 - "net/http" 6 - ) 7 - 8 - type Client struct { 9 - cli *http.Client 10 - baseURL string 11 - headers http.Header 12 - } 13 - 14 - func New(token string, userAgent string) *Client { 15 - headers := http.Header{} 16 - headers.Set("Authorization", token) 17 - headers.Set("User-Agent", userAgent) 18 - 19 - cli := &http.Client{} 20 - 21 - return &Client{ 22 - cli: cli, 23 - baseURL: "https://mi.within.website", 24 - headers: headers, 25 - } 26 - } 27 - 28 - func (c *Client) Refresh() error { 29 - if c == nil { 30 - return nil 31 - } 32 - 33 - req, err := http.NewRequest("POST", c.baseURL+"/api/blog/refresh", nil) 34 - if err != nil { 35 - return err 36 - } 37 - 38 - for k, v := range c.headers { 39 - req.Header[k] = v 40 - } 41 - 42 - resp, err := c.cli.Do(req) 43 - if err != nil { 44 - return err 45 - } 46 - defer resp.Body.Close() 47 - 48 - if resp.StatusCode != http.StatusOK { 49 - return errors.New("non-200 status code") 50 - } 51 - 52 - return nil 53 - }