mirror of
https://github.com/codl/forget
synced 2024-12-25 06:32:15 +01:00
disable archives
it has come to my attention while investigating #263 that tweet archives as forget supports them are no longer a thing. this commit disables all front-facing archive support and puts a banner above the form
This commit is contained in:
parent
c5c4b72c6f
commit
9592ab8511
@ -1,5 +1,4 @@
|
||||
import Banner from '../components/Banner.html';
|
||||
import ArchiveForm from '../components/ArchiveForm.html';
|
||||
import {known_load, known_save} from './known_instances.js'
|
||||
|
||||
(function settings_init(){
|
||||
@ -195,19 +194,6 @@ import {known_load, known_save} from './known_instances.js'
|
||||
})
|
||||
}
|
||||
|
||||
let archive_form_el = document.querySelector('#archive-form');
|
||||
if(archive_form_el){
|
||||
let csrf_token = archive_form_el.querySelector('input[name=csrf-token]').value;
|
||||
let archive_form = new ArchiveForm({
|
||||
target: archive_form_el,
|
||||
hydrate: true,
|
||||
data: {
|
||||
action: archive_form_el.action,
|
||||
csrf_token: csrf_token,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function bump_instance(instance_name){
|
||||
let known_instances = known_load();
|
||||
let found = false;
|
||||
|
@ -1,38 +0,0 @@
|
||||
<form action={action} method='post' enctype='multipart/form-data'>
|
||||
{#if file_too_big}
|
||||
<div class="banner warning">
|
||||
<p>The file you have selected is very large.</p>
|
||||
|
||||
<p>Twitter has two types of archives, <b>Forget does not support
|
||||
"Your Twitter data" archives, only "Tweet archives"</b>
|
||||
available from
|
||||
<a href="https://twitter.com/settings/account#export_request">your account settings</a>.
|
||||
Please make sure you have the right type of archive.</p>
|
||||
</div>
|
||||
{/if}
|
||||
<input type="file" name="file" accept="application/zip,.zip"
|
||||
on:change={take_file(this.files)}>
|
||||
<input type="submit" value="Upload">
|
||||
<input type='hidden' name='csrf-token' value={csrf_token}>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
export let csrf_token, action;
|
||||
|
||||
function get_file_size(file_list){
|
||||
/* returns size of selected file given an <input type="file">
|
||||
or 0 if no file is selected */
|
||||
let size = 0;
|
||||
for(let i = 0; i < file_list.length; i++){
|
||||
size += file_list[i].size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
function take_file(file_list){
|
||||
file_size: get_file_size(file_list);
|
||||
}
|
||||
|
||||
let file_size = 0;
|
||||
$: file_too_big = file_size > 10000000; // 10 MB
|
||||
</script>
|
@ -93,38 +93,9 @@ def twitter_login_step2():
|
||||
url_for('about', twitter_login_error='', _anchor='log_in'))
|
||||
|
||||
|
||||
class TweetArchiveEmptyException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@app.route('/upload_tweet_archive', methods=('POST',))
|
||||
@require_auth
|
||||
def upload_tweet_archive():
|
||||
ta = TwitterArchive(
|
||||
account=g.viewer.account,
|
||||
body=request.files['file'].read())
|
||||
db.session.add(ta)
|
||||
db.session.commit()
|
||||
|
||||
try:
|
||||
files = libforget.twitter.chunk_twitter_archive(ta.id)
|
||||
|
||||
ta.chunks = len(files)
|
||||
db.session.commit()
|
||||
|
||||
if not ta.chunks > 0:
|
||||
raise TweetArchiveEmptyException()
|
||||
|
||||
for filename in files:
|
||||
tasks.import_twitter_archive_month.s(ta.id, filename).apply_async()
|
||||
|
||||
return redirect(url_for('index', _anchor='recent_archives'))
|
||||
except (BadZipFile, TweetArchiveEmptyException):
|
||||
if sentry:
|
||||
sentry.captureException()
|
||||
return redirect(
|
||||
url_for('index', tweet_archive_failed='',
|
||||
_anchor='tweet_archive_import'))
|
||||
return 403, 'Tweet archive support is temporarily disabled, see banner on the front page.'
|
||||
|
||||
|
||||
@app.route('/settings', methods=('POST',))
|
||||
|
@ -148,8 +148,10 @@
|
||||
<div class="banner error">The file you uploaded is not a valid tweet archive. No posts have been imported.</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="banner warning">Archive imports are temporarily disabled. The tweet archive format has been quietly dropped by Twitter and replaced by a more comprehensive data archive format. Support for this format will come soon.</div>
|
||||
|
||||
<form action='{{url_for('upload_tweet_archive')}}' method='post' enctype='multipart/form-data' id='archive-form'>
|
||||
<input type="file" name='file' accept='application/zip,.zip'><input type="submit" value="Upload">
|
||||
<input disabled type="file" name='file' accept='application/zip,.zip'><input disabled type="submit" value="Upload">
|
||||
<input type='hidden' name='csrf-token' value='{{g.viewer.csrf_token}}'>
|
||||
</form>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user