This commit is contained in:
parent
7ed545b8fb
commit
f149cffbdb
2
LICENSE
2
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
|
||||
|
74
README.md
74
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).
|
||||
|
22
blurp.go
22
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,6 +180,7 @@ var deleteCmd = &cobra.Command{
|
||||
|
||||
numHours := time.Duration(168 * weeks)
|
||||
if t.Before(time.Now().Add(-time.Hour * numHours)) {
|
||||
if !dry {
|
||||
_, err := authClient.Client.Statuses.StatusDelete(&statuses.StatusDeleteParams{
|
||||
ID: status.ID,
|
||||
}, authClient.Auth)
|
||||
@ -181,8 +188,13 @@ var deleteCmd = &cobra.Command{
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user