feat: implements today command

This commit is contained in:
Dennis Schoepf 2025-08-28 17:59:31 +02:00
parent 09f4b2a838
commit a77d4f9604
5 changed files with 101 additions and 14 deletions

30
internal/article.go Normal file
View file

@ -0,0 +1,30 @@
package internal
import (
"fmt"
"freed/internal/database"
)
func GetArticleUrlForToday() (string, error) {
count, err := database.CountArticlesReadToday()
if err != nil {
return "", err
}
if count > 0 {
return "", fmt.Errorf("Already reached maximum number of articles for the day. Come back tomorrow!")
}
article, err := database.FindOneUnreadArticle()
if err != nil {
return "", err
}
if err := article.MarkAsRead(); err != nil {
return "", err
}
return article.Url, nil
}