Compare commits

...

10 commits
v2.0.1 ... main

Author SHA1 Message Date
TheWanderingCrow
eb74f08b2c add hydraJobs to flake 2026-01-30 16:17:51 -05:00
3da46bd0a7 chore: Update README.md 2026-01-20 15:44:39 -05:00
TheWanderingCrow
874eb0eff1 chore: v2.0.2 release 2026-01-20 15:40:08 -05:00
TheWanderingCrow
dc093bcade fix: fix regressions 2026-01-20 15:36:25 -05:00
TheWanderingCrow
215a0fde7c chore: flake updates for v2.0.1 release 2026-01-20 10:43:59 -05:00
TheWanderingCrow
1c1b2a3a1d fix!: SMTP now works properly in non-dev environments 2025-12-30 21:50:16 -05:00
TheWanderingCrow
43d4e6caee chore: update sha256 2025-12-30 21:21:02 -05:00
TheWanderingCrow
00104dc59a docs: fix syntax error in README.md 2025-12-27 11:04:28 -05:00
TheWanderingCrow
ae765605d9 chore: release v1.0 2025-12-27 10:57:43 -05:00
TheWanderingCrow
6eb0beb355 add support for encryption key protected budget files 2025-12-27 10:45:49 -05:00
3 changed files with 32 additions and 18 deletions

View file

@ -15,7 +15,7 @@ Then in your configuration (using sops-nix, you will need to adjust it if you us
nixpkgs.overlays = [ inputs.actualbudget-report.overlays.default ];
imports = [
inputs.actualbudget-report.nixosModules.default;
inputs.actualbudget-report.nixosModules.default
];
# Fill out all the following environment variables for the service
@ -26,7 +26,9 @@ sops.templates."actualbudget-report-env".content = ''
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_HOST=
SMTP_PORT=
SMTP_RECIPIENTS=
BUDGET_ENCRYPTION_KEY=
'';
services.actualbudget-report = {

View file

@ -24,7 +24,15 @@
"aarch64-darwin"
"x86_64-darwin"
];
flake.nixosModules.default = ./modules/actualbudget-report;
flake = {
nixosModules.default = ./modules/actualbudget-report;
hydraJobs = {
inherit (self)
packages
;
};
};
perSystem =
{
config,
@ -42,8 +50,8 @@
domain = "git.wanderingcrow.net";
owner = "TheWanderingCrow";
repo = "actualbudget-report";
rev = "v0.1";
hash = "sha256-1Z3+Efx0MCsZhfz49nKsdaWgyVt9+7kekwgfQyaYUxQ=";
rev = "v2.0.2";
hash = "sha256-vnd1RvlMD4WOLtXpIOiPxuDxvHoBQVTP/8l/OMWR5No=";
};
vendorHash = "sha256-NHTKwUSIbNCUco88JbHOo3gt6S37ggee+LWNbHaRGEs=";
};

32
main.go
View file

@ -32,10 +32,11 @@ import (
)
type BudgetClient struct {
baseUrl string
apiKey string
syncId string
fullUrl string
baseUrl string
apiKey string
syncId string
fullUrl string
encryptionKey string
}
type BudgetMonthsResponse struct {
@ -73,9 +74,12 @@ type BudgetMonthsResponse struct {
} `json:"data"`
}
func CreateBudgetClient(baseUrl string, apiKey string, syncId string) *BudgetClient {
// Create budget client, you may pass empty strings to optional parameters
// Required: baseUrl, apiKey, syncId
// Optional: encryptionKey
func CreateBudgetClient(baseUrl string, apiKey string, syncId string, encryptionKey string) *BudgetClient {
fullUrl := baseUrl + "/v1/budgets/" + syncId
client := BudgetClient{baseUrl, apiKey, syncId, fullUrl}
client := BudgetClient{baseUrl, apiKey, syncId, fullUrl, encryptionKey}
return &client
}
@ -111,7 +115,9 @@ func (b BudgetClient) GetBudgetMonths() *BudgetMonthsResponse {
currentTime := time.Now()
year, month := currentTime.Year(), int(currentTime.Month())
budgetMonth := fmt.Sprintf("%v-%02d", year, month)
resp := b.callApi("GET", "/months/"+budgetMonth, nil)
resp := b.callApi("GET", "/months/"+budgetMonth, map[string]string{
"budget-encryption-password": b.encryptionKey,
})
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
temp, _ := io.ReadAll(resp.Body)
@ -140,11 +146,13 @@ func main() {
var baseUrl = os.Getenv("BASE_URL")
var apiKey = os.Getenv("API_KEY")
var syncId = os.Getenv("SYNC_ID")
var encryptionKey = os.Getenv("BUDGET_ENCRYPTION_KEY")
var smtpUsername = os.Getenv("SMTP_USERNAME")
var smtpPassword = os.Getenv("SMTP_PASSWORD")
var smtpHost = os.Getenv("SMTP_HOST")
var smtpPort = os.Getenv("SMTP_PORT")
var smtpRecipients = os.Getenv("SMTP_RECIPIENTS")
client := CreateBudgetClient(baseUrl, apiKey, syncId)
client := CreateBudgetClient(baseUrl, apiKey, syncId, encryptionKey)
if !client.BankSync() {
log.Println("Bank Sync failed, information may not be up to date")
}
@ -178,12 +186,8 @@ func main() {
message := []byte(subject + mime + body + categories.String())
var auth smtp.Auth
if os.Getenv("ENVIRONMENT") == "dev" {
auth = nil
} else {
auth = smtp.PlainAuth("", smtpUsername, smtpPassword, smtpHost)
}
err := smtp.SendMail(smtpHost, auth, smtpUsername, strings.Split(smtpRecipients, ","), []byte(message))
auth = smtp.PlainAuth("", smtpUsername, smtpPassword, smtpHost)
err := smtp.SendMail(smtpHost+":"+smtpPort, auth, smtpUsername, strings.Split(smtpRecipients, ","), []byte(message))
if err != nil {
log.Fatal(err)
}