Skip to content

Commit

Permalink
Merge pull request #79 from solun-pm/dev
Browse files Browse the repository at this point in the history
Fixed error on file and msg and made it more secure
  • Loading branch information
DanielWTE authored Jun 23, 2023
2 parents 297640b + 80db2fb commit 42bdb5d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,45 @@ jobs:
- name: Restart Node 2
run: |
curl -X POST ${{ secrets.WEBHOOK_DOMAIN }}/hooks/restart-app-2
- name: Setup Node.js environment
uses: actions/setup-node@v2.4.1

- name: Discord Webhook for Main
if: github.ref == 'refs/heads/main'
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
COMMIT_LINK="https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
curl -X POST ${{ secrets.DISCORD_WEBHOOK }} \
-H "Content-Type: application/json" \
-d '{
"embeds": [{
"title": "New Production Version deployed on solun.pm",
"url": "https://solun.pm",
"description": "[Changes]('$COMMIT_LINK')",
"fields": [
{ "name": "Version", "value": "'$PACKAGE_VERSION'", "inline": false }
],
"color": 255
}]
}'
- name: Discord Webhook for Dev
if: github.ref == 'refs/heads/dev'
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
COMMIT_LINK="https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
curl -X POST ${{ secrets.DISCORD_WEBHOOK }} \
-H "Content-Type: application/json" \
-d '{
"embeds": [{
"title": "New Development Version deployed on dev.solun.pm",
"url": "https://dev.solun.pm",
"description": "[Changes]('$COMMIT_LINK')",
"fields": [
{ "name": "Version", "value": "'$PACKAGE_VERSION'", "inline": false }
],
"color": 16753920
}]
}'
3 changes: 1 addition & 2 deletions app/file/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function UploadFile() {
const passwordSet = password !== "";
const encrypted_password = passwordSet ? await hashPassword(password) : null;


if (files.length > 0) {
const formData = new FormData();
formData.append('file', files[0]);
Expand Down Expand Up @@ -143,7 +142,7 @@ function UploadFile() {
setUploadLink(data.link);
setUploadCreated(true);
} else {
alert(data.message);
toast.error(data.message);
}
} catch (err) {
toast.error('There was an error uploading your file');
Expand Down
10 changes: 7 additions & 3 deletions app/msg/[...data]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ function ViewMessage({ params }: { params: { data: string[] } }) {
async function handleViewMessage(secretKey: string) {
setLoading(true);
setError("");
const data = {

const data: any = {
id,
password,
secret: secretKey,
};

if(secretKey === ""){
data.secret = secretKey;
}
const res = await fetch(process.env.NEXT_PUBLIC_API_DOMAIN + '/message/receive', {
method: "POST",
headers: {
Expand All @@ -86,7 +90,7 @@ function ViewMessage({ params }: { params: { data: string[] } }) {
toast.error(result.message);
} else {
const serect_key = result.secret || secretKey;
const decryptedMessage = await decrypt(result.message, serect_key);
const decryptedMessage = await decrypt(result.message, serect_key as string);
setMessage(decryptedMessage);
setShowMessage(true);

Expand Down
8 changes: 6 additions & 2 deletions app/msg/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function CreateMessage() {
const passwordSet = password !== "";
const encrypted_password = passwordSet ? await hashPassword(password) : null;

const dbSecretKey = endToEndEncryption ? secret_key : null;
const dbSecretKey = endToEndEncryption ? null : secret_key;

const data = {
mid,
Expand All @@ -133,7 +133,11 @@ function CreateMessage() {
submitButton.innerHTML = 'Create';
} else {
setMessageCreated(true);
setMessageLink(result.link);
let resultLink = result.link;
if (dbSecretKey === null) {
resultLink += `${secret_key}/`;
}
setMessageLink(resultLink);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "solun",
"version": "0.1.3",
"version": "0.3.5",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"version": "git add .",
"postversion": "git push"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.0",
Expand Down
File renamed without changes.

0 comments on commit 42bdb5d

Please sign in to comment.