37 lines
		
	
	
		
			805 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			805 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package handler
 | |
| 
 | |
| import (
 | |
| 	"errors"
 | |
| 	"fmt"
 | |
| 	"log/slog"
 | |
| 
 | |
| 	"github.com/spf13/viper"
 | |
| 
 | |
| 	"git.kplus.net.ua/yevhen/resource-scraper/types/constant"
 | |
| )
 | |
| 
 | |
| func (h *Handler) STB() string {
 | |
| 	endpoint := fmt.Sprintf("%s.%s", constant.ScopeShareTheBrutality, constant.CfgKeyEndpoint)
 | |
| 	endpoint = viper.GetString(endpoint)
 | |
| 
 | |
| 	if endpoint == "" {
 | |
| 		slog.Error("getting endpoint from config", "err", errors.New("no endpoint provided"))
 | |
| 		return "stb"
 | |
| 	}
 | |
| 
 | |
| 	es, ms := h.services.ShareTheBrutality.GetMail(endpoint)
 | |
| 
 | |
| 	//fmt.Printf("%+v\n", es)
 | |
| 	ms.LogOut()
 | |
| 
 | |
| 	for _, record := range es {
 | |
| 		fmt.Printf("%s %d: %s [#%s]\n", record.Created, record.Id, record.Title, record.Releaser)
 | |
| 	}
 | |
| 
 | |
| 	/*if err != nil {
 | |
| 		slog.Error("error occurred while getting topic: ", "err", err)
 | |
| 	}*/
 | |
| 
 | |
| 	return fmt.Sprintf("Added %d records\n", len(es))
 | |
| }
 |