diff --git a/LICENSE b/LICENSE index 42dfd5e..a40793e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -blurp: A GoToSocial status deletion tool. +blurp: A GoToSocial status management tool. Copyright (C) 2024 decentral1se This program is free software: you can redistribute it and/or modify it under diff --git a/README.md b/README.md index 7fa9638..2bca34b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,11 @@ > 🚧 Status: **ALPHA SOFTWARE** 🚧 -A [GoToSocial](https://docs.gotosocial.org) status deletion tool. Given that this can completely destroy your status history, I'm not sure I really recommend it. However, it does Work For Me ™ `blurp` might be useful to you while we're waiting for [`#1442`](https://github.com/superseriousbusiness/gotosocial/issues/1442) to get implemented. +A [GoToSocial](https://docs.gotosocial.org) status management tool. + +`blurp` might be useful to you while we're waiting for +[`#1442`](https://github.com/superseriousbusiness/gotosocial/issues/1442) to +get implemented. ## Install @@ -15,6 +19,42 @@ curl https://git.coopcloud.tech/decentral1se/blurp/raw/branch/main/blurp -o blur chmod +x blurp ``` +## Delete stuff 🔥 + +You'll need to log in first: + +``` +blurp login -u foo@bar.zone +``` + +You can archive all your account statuses: + +``` +blurp archive +``` + +See `./archive` for every status (favourited, pinned, boosted, bookmarked etc.) +connected with your account. All media attachments are downloaded alongside the +status. Status content is dumped as a JSON file. + +> 🔴 **DANGER ZONE** 🔴 + +To delete all statuses older than *2 weeks*: + +``` +blurp delete +``` + +It is **HIGHLY RECOMMENDED** to pass `--dry/-d` as a dry run before actually +deleting stuff or real. This lets `blurp` tell you what it will actually do +before doing it. Avoid heartache, always `--dry`. + +You can use `--weeks/-w` to supply a value for "number of weeks". If you need +to send less requests, say, 1 request every 3 seconds, you can pass `-r 3`. See +`--help` for more. + +> 🔴 **DANGER ZONE** 🔴 + ## Field notes on how deletion works in GoToSocial > 🟡 How this exactly works seems to depend both on a shifting development sands @@ -56,38 +96,6 @@ chmod +x blurp be nice to run `blurp` at some "less busy" time period (but yanno, timezones, so 🤷) and/or consider more strict rate limiting (`--rate/-r`). -## Delete stuff 🔥 - -You'll need to log in first: - -``` -blurp login -u foo@bar.zone -``` - -You might want to archive stuff locally: - -``` -blurp archive -``` - -See `./archive` for every status (favourited, pinned, boosted, bookmarked etc.) -connected with your account. All media attachments are downloaded alongside the -status. Status content is dumped as a JSON file. - -> 🔴 **DANGER ZONE** 🔴 - -To delete all statuses older than *2 weeks*: - -``` -blurp delete -``` - -You can use `--weeks/-w` to supply a value for "number of weeks". If you need -to send less requests, say, 1 request every 3 seconds, you can pass `-r 3`. See -`--help` for more. - -> 🔴 **DANGER ZONE** 🔴 - ## ACK Made possible by the good work of [slurp](https://github.com/VyrCossont/slurp). diff --git a/blurp b/blurp index 9092364..796e519 100755 Binary files a/blurp and b/blurp differ diff --git a/blurp.go b/blurp.go index a41e106..b897aae 100644 --- a/blurp.go +++ b/blurp.go @@ -22,9 +22,10 @@ import ( ) var ( - user string - weeks int - rate int + user string // account username + weeks int // number of weeks of statuses to retain + rate int // requests per second + dry bool // whether or not to run in dry mode ) func init() { @@ -36,6 +37,7 @@ func init() { deleteCmd.Flags().IntVarP(&weeks, "weeks", "w", 2, "keep statuses NEWER than no. of weeks") deleteCmd.Flags().IntVarP(&rate, "rate", "r", 1, "send a request every 'r' seconds") + deleteCmd.Flags().BoolVarP(&dry, "dry", "d", false, "dry run mode (NO DELETION)") rootCmd.AddCommand(deleteCmd) } @@ -50,7 +52,7 @@ func main() { // rootCmd is the root command. var rootCmd = &cobra.Command{ Use: "blurp", - Short: "A GoToSocial status deletion tool", + Short: "A GoToSocial status management tool", } // loginCmd is the login command. @@ -152,6 +154,10 @@ var deleteCmd = &cobra.Command{ slog.Info(fmt.Sprintf("keeping statuses NEWER than %d weeks", weeks)) + if dry { + slog.Info("DRY RUN MODE ENABLED - STATUS DELETION DISABLED") + } + acc, err := getAccount(authClient) if err != nil { slog.Error("unable to retrieve account", "error", err) @@ -174,15 +180,21 @@ var deleteCmd = &cobra.Command{ numHours := time.Duration(168 * weeks) if t.Before(time.Now().Add(-time.Hour * numHours)) { - _, err := authClient.Client.Statuses.StatusDelete(&statuses.StatusDeleteParams{ - ID: status.ID, - }, authClient.Auth) - if err != nil { - slog.Error("unable to delete status", "error", err) - os.Exit(1) + if !dry { + _, err := authClient.Client.Statuses.StatusDelete(&statuses.StatusDeleteParams{ + ID: status.ID, + }, authClient.Auth) + if err != nil { + slog.Error("unable to delete status", "error", err) + os.Exit(1) + } } - slog.Info(fmt.Sprintf("deleted %s (created: %s)", status.ID, t.Format(time.DateOnly))) + msg := fmt.Sprintf("deleted %s (created: %s)", status.ID, t.Format(time.DateOnly)) + if dry { + msg = fmt.Sprintf("DRY RUN: %s", msg) + } + slog.Info(msg) time.Sleep(time.Duration(rate)) } else {