diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 58ca2ebc..00142a83 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,8 @@ +[0.7.1] +[+] reactions CRUL +[+] upload with storj + + [0.7.0] [+] inbox: context provider, chats [+] comments: show diff --git a/api/upload.py b/api/upload.py index 28a02911..d3b5b064 100644 --- a/api/upload.py +++ b/api/upload.py @@ -1,4 +1,4 @@ -from flask import Flask, request +from flask import Flask, request, jsonify from werkzeug.utils import secure_filename import boto3 from botocore.exceptions import ClientError, WaiterError @@ -17,7 +17,7 @@ storj_client = boto3.client('s3', def upload_storj(filecontent, filename, bucket_name): head = None - + bucket_obj = None try: bucket = storj_resource.Bucket(bucket_name) except ClientError: @@ -33,22 +33,22 @@ def upload_storj(filecontent, filename, bucket_name): etag = head['ETag'].strip('"') try: - s3_obj = bucket.Object(filename) + bucket_obj = bucket.Object(filename) except (ClientError, AttributeError): - s3_obj = None + bucket_obj = None try: # Use the upload_fileobj method to safely upload the file storj_client.upload_fileobj( Fileobj=filecontent, - Bucket='discours.io', + Bucket=bucket_name, Key=filename ) except (ClientError, AttributeError): pass else: try: - s3_obj.wait_until_exists(IfNoneMatch=etag) + bucket_obj.wait_until_exists(IfNoneMatch=etag) except WaiterError: pass else: @@ -56,22 +56,21 @@ def upload_storj(filecontent, filename, bucket_name): return head -@app.route('/upload', methods=['post']) +@app.route('/api/upload', methods=['post']) def upload(): - if request.method == 'POST': - img = request.files['file'] - if img: - # Perform the file upload - filename = secure_filename(img.filename) - # Save the file to a temporary location - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = os.path.join(temp_dir, filename) - img.save(temp_path) - # Open the file in binary mode - with open(temp_path, 'rb') as filecontent: - return upload_storj(filecontent, filename, 'discours.io') + print('upload serverless route is fine') + print(request.path) + print(request.form) + print(request.files) + img = request.files['file'] + if img: + # Perform the file upload + filename = secure_filename(img.filename) + # Save the file to a temporary location + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = os.path.join(temp_dir, filename) + img.save(temp_path) + # Open the file in binary mode + with open(temp_path, 'rb') as filecontent: + return jsonify(upload_storj(filecontent, filename, 'discoursio')) return - - -if __name__ == "__main__": - app.run() diff --git a/src/components/Pages/profile/ProfileSettingsPage.tsx b/src/components/Pages/profile/ProfileSettingsPage.tsx index 81804182..dc4b7b67 100644 --- a/src/components/Pages/profile/ProfileSettingsPage.tsx +++ b/src/components/Pages/profile/ProfileSettingsPage.tsx @@ -37,6 +37,7 @@ export const ProfileSettingsPage = (props: PageProps) => { formData.append('type', file.type) formData.append('name', image.source.split('/').pop()) formData.append('ext', image.name.split('.').pop()) + formData.append('data', image.file) const resp = await fetch('/api/upload', { method: 'POST', body: formData diff --git a/src/components/_shared/Popup/Popup.module.scss b/src/components/_shared/Popup/Popup.module.scss index 27d1bde8..3325cc7c 100644 --- a/src/components/_shared/Popup/Popup.module.scss +++ b/src/components/_shared/Popup/Popup.module.scss @@ -4,18 +4,19 @@ .popup { background: #fff; - top: calc(100% + 8px); - opacity: 1; color: #000; - position: absolute; - z-index: 100; min-width: 144px; + opacity: 1; + position: absolute; + top: calc(100% + 8px); + z-index: 100; ul { margin-bottom: 0; li { position: relative; + &:last-child { margin-bottom: 0; } @@ -24,11 +25,12 @@ &.bordered { @include font-size(1.6rem); - border: 2px solid #000; padding: 2.4rem; + ul li { margin-bottom: 1.6rem; + &:last-child { margin-bottom: 0; } @@ -37,11 +39,12 @@ &.tiny { @include font-size(1.4rem); - box-shadow: 0 4px 60px rgba(0, 0, 0, 0.1); padding: 1rem; + ul li { margin-bottom: 1rem; + &:last-child { margin-bottom: 0; } diff --git a/src/pages/[...slug].astro b/src/pages/[...slug].astro index 1fd64acd..7328608d 100644 --- a/src/pages/[...slug].astro +++ b/src/pages/[...slug].astro @@ -4,8 +4,20 @@ import Prerendered from '../main.astro' import { apiClient } from '../utils/apiClient' import { initRouter } from '../stores/router' +const excludes = [ + 'authors', + 'connect', + 'create', + 'inbox', + 'search', + 'topics', + 'welcome', + 'confirm', + 'feed' +] + const slug = Astro.params.slug?.toString() -if (slug.endsWith('.map')) { +if (slug.endsWith('.map') || slug in excludes) { return Astro.redirect('/404') } diff --git a/src/utils/apiClient.ts b/src/utils/apiClient.ts index bfa35018..a3132aa6 100644 --- a/src/utils/apiClient.ts +++ b/src/utils/apiClient.ts @@ -12,8 +12,8 @@ import type { MutationCreateMessageArgs, Chat, QueryLoadRecipientsArgs, - ReactionBy, - ProfileInput + ProfileInput, + ReactionBy } from '../graphql/types.gen' import { publicGraphQLClient } from '../graphql/publicGraphQLClient' import { getToken, privateGraphQLClient } from '../graphql/privateGraphQLClient'