remove auth requirement for posting

main
lza_menace 3 years ago
parent 408062368e
commit ecec8de6e4

@ -30,10 +30,7 @@ def upload_to_ipfs(meme_id: str):
'image': f'ipfs://{artwork_hash}',
'create_date': meme.create_date.strftime('%Y-%m-%d %H:%M:%S'),
'file_name': meme.file_name,
'ipfs_hash': artwork_hash,
'properties': {
'creator_address': meme.user.public_address
}
'ipfs_hash': artwork_hash
}
meta_hash = client.add_json(meta)
print(f'[+] Uploaded metadata to IPFS: {meta_hash}')

@ -40,9 +40,6 @@ def mod():
@bp.route('/publish', methods=['GET', 'POST'])
def publish():
if not current_user.is_authenticated:
flash('You need to connect your wallet first.', 'warning')
return redirect(url_for('meme.index'))
meme = None
try:
client = ipfsApi.Client('127.0.0.1', 5001)
@ -64,16 +61,19 @@ def publish():
)
full_path = f'{config.DATA_FOLDER}/uploads/{filename}'
file.save(full_path)
id = None
if current_user.is_authenticated:
id = current_user.id
try:
meme = Meme(
file_name=filename,
title=title,
description=description,
user_id=current_user.id
user_id=id
)
db.session.add(meme)
db.session.commit()
if current_user.verified or current_user.moderator:
if current_user.is_authenticated and (current_user.verified or current_user.moderator):
res = upload_to_ipfs(meme.id)
meme.meta_ipfs_hash = res[0]
meme.meme_ipfs_hash = res[1]

@ -27,9 +27,11 @@
</div>
<div class="media-content">
<p class="title is-4">{{ meme.title }}</p>
{#
<p class="subtitle is-6">
<a href="{{ meme.user.public_address | show_etherscan }}" target="_blank">({{ meme.user.public_address | shorten_address }})</a>
</p>
#}
</div>
</div>

@ -25,10 +25,10 @@
{% if current_user.moderator %}
<a class="button is-warning" href="{{ url_for('meme.mod') }}" up-preload up-follow=".container">Mod</a>
{% endif %}
<a class="button is-primary" href="{{ url_for('meme.publish') }}" up-follow=".container">New Meme</a>
{% else %}
<a class="button is-primary" id="metamaskConnect" onclick="onboardMetaMask();">Connect</a>
<a class="button is-warning" id="metamaskConnect" onclick="onboardMetaMask();">Connect</a>
{% endif %}
<a class="button is-primary" href="{{ url_for('meme.publish') }}" up-follow=".container">New Meme</a>
</div>
</div>
</div>

@ -36,7 +36,6 @@
</a>
<hr>
<p><strong>Poster Address: </strong></br><span style="word-wrap: break-word"><a href="{{ meme.user.public_address | show_etherscan }}" target="_blank">{{ meme.user.public_address }}</a></span></p>
{% if meme.meta_ipfs_hash %}
<p><strong>Metadata IPFS:</strong></br><a href="{{ meta_url }}" target="_blank">{{ meme.meta_ipfs_hash }}</a></p>
{% endif %}

@ -15,13 +15,6 @@
</div>
</div>
<div class="field">
<label class="label">Poster Address</label>
<div class="control">
<p>{{ current_user.public_address }}</p>
</div>
</div>
<div class="field">
<label class="label">Title</label>
<div class="control">

Loading…
Cancel
Save