mastodon-importer/README.md

36 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2022-09-15 09:59:07 +00:00
# Mastodon Importer
A simple script to start playing with mastodon importing toots. It's just a startpoint because it's not fully usable yet.
It uses a `sample.json` file as input (you can get this file in your mastodon instance server, under preferences + export information).
## Warning
2022-09-15 10:05:27 +00:00
As said, it's not fully usable yet, it's a WIP (for now it's not looping over all the json data, it just creates a hello world toot in the account with id=1), but it could be a good startpoint if you need a tool like this.
2022-09-15 09:59:07 +00:00
## Guidelines
2022-09-22 16:22:12 +00:00
* Get your `sample.json` from your mastodon instance server.
* Preferences
2022-09-15 09:59:07 +00:00
* Import and Export
* Request your data
* Extract the zip and get the `outbox.json`
* Modify the code to match the path of your `outbox.json`
* Create a `.env` file with your postgresql credentials from the `.env.sample` file in the repo.
* Run and/or compile this script:
* `go run`
2022-09-22 16:33:36 +00:00
* `go build`. Take in account **where** you will run the binary. I mean I've developed it under macos darwin but I wanted to run it on my mastodon instance machine, so I compiled it with some flags in order to get it running: `GOOS=linux GOARCH=amd64 go build`.
2022-09-15 09:59:07 +00:00
* Move the binary and the `outbox.json` to the server (ensure path matches) and profit.
## Resources
- [UnmarshalJSON stuff](https://medium.com/@nate510/dynamic-json-umarshalling-in-go-88095561d6a0)
- [godotenv](https://golangbyexample.com/load-env-fiie-golang/)
- [Something similar but in JS](https://gitlab.com/umonaca/mastodon-toots-migration-queries-generator/-/blob/cat/index.js)
- [How to migrate from one Mastodon server to another one](https://mastodon.social/@Gargron/103393780267601137)
## Final notes
2022-09-15 09:59:07 +00:00
2022-09-15 10:05:27 +00:00
Feel free to modify the script in order to fill your needs. Of course, mentions and patches (PRs, etc...) are more than welcome!