-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Backup / Export Filters #89
Comments
Yeah, a bit like archiving accounts? I'm not quite convinced that I'd ever want to look at them… but who knows. |
Sort of - but the use case I was thinking of was if you wanted to manage filters across multiple accounts. Personally I have a huge list of filters and if for whatever reason the instance I am currently on went away I'd have to craft them all again. Last night I had a crack at exporting them using a JS/TS library called Megalodon which made it surprisingly easy to export filters to JSON async function filters() {
const filters = await client.getFilters();
return filters.data;
}
function backupFilters() {
filters().then((filterObj) => {
const json = JSON.stringify(filterObj, null, 2);
fs.writeFileSync(`${outdir}/filters.json`, json);
});
} |
It sounds like this wouldn't be all that useful unless there was also a way to upload those filters to a different account… |
You can! Here's an example I whipped up using that same JS/TS library: async function uploadFilters(json: string) {
const filterObj = JSON.parse(json);
filterObj.forEach((filter: Entity.Filter) => {
client.createFilter(filter.phrase, filter.context);
});
} Src: https://github.com/sammcj/mastapi/blob/main/src/upload.ts |
Interesting. If somebody adds it to mastodon-archive, I guess that would make sense. It'll need more command line arguments and all that, for sure. |
Strong second for exporting filters. I also have a huge number of filters. I've invested many hours in creating and improving them. Not only do I want them to be portable to other instances, I also want to back the filters up for BC/DR purposes (in case that instance is somehow lost, the instance accidentally deletes my filters, etc.). |
If somebody writes it, I'll add it. |
For reference to anyone willing to try to implement it, here is the related API : https://docs.joinmastodon.org/methods/filters/ |
It would be awesome if this tool could backup / export your Filters, currently I don't think there is a way to do this.
The text was updated successfully, but these errors were encountered: