Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Feat/3speak video upload #1353

Merged
merged 56 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
515a4ad
editor video icon
Adesojisouljay Dec 28, 2022
31558eb
test input
Adesojisouljay Mar 15, 2023
64e7e35
test file
Adesojisouljay Mar 17, 2023
1c0a66c
uploads handlers
Adesojisouljay Mar 17, 2023
c9da697
fixed bug
Adesojisouljay Mar 20, 2023
e9fbedc
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Mar 21, 2023
c75a409
fixed style
Adesojisouljay Mar 21, 2023
3246911
insert video text
Adesojisouljay Mar 25, 2023
e4a6b4b
logic fixes
Adesojisouljay Mar 27, 2023
af6a7c8
change upload logic
Adesojisouljay Apr 3, 2023
b429539
sec changes
Adesojisouljay Apr 4, 2023
cfec5a2
logic fixes
Adesojisouljay Apr 4, 2023
6c188d2
move modal to video component
Adesojisouljay Jun 1, 2023
13fd8b4
change styles
Adesojisouljay Jun 1, 2023
caaa1ae
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Jun 3, 2023
4b06aa7
fix speak logics
Adesojisouljay Jun 9, 2023
63ca9b1
video gallery
Adesojisouljay Jun 12, 2023
99c9683
fix translations
Adesojisouljay Jun 13, 2023
ab50abc
fix video info
Adesojisouljay Jun 14, 2023
ae2f6db
fix memo decoding with hivesigner
feruzm Jun 16, 2023
b3ad184
linting
feruzm Jun 16, 2023
16f83b4
fix preview and gallery memo
Adesojisouljay Jun 19, 2023
def2357
fix encoder beneficiary
Adesojisouljay Jun 20, 2023
2d67526
embed video fixes
Adesojisouljay Jun 21, 2023
7048499
fix post publishing
Adesojisouljay Jun 23, 2023
84cb7e7
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Jun 26, 2023
7034f5b
mark as published
Adesojisouljay Jun 26, 2023
0af462b
beneficiary and dropdown
Adesojisouljay Jun 30, 2023
fd27a86
persiting beneficiary and iPublished endpoint
Adesojisouljay Jul 1, 2023
9afc1e4
fix video duration
Adesojisouljay Jul 2, 2023
d426136
remove iframe scroll bar
Adesojisouljay Jul 2, 2023
f0679a2
add confirm nsfw content
Adesojisouljay Jul 3, 2023
44c698f
checkbox styles and save nsfw advanced
Adesojisouljay Jul 3, 2023
3a6d13b
remove iframe
Adesojisouljay Jul 19, 2023
78f850e
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Jul 19, 2023
b20baf2
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Jul 19, 2023
fcda7e2
Merge branch 'development' into feat/3speak-video-upload
feruzm Jul 21, 2023
ba92218
improve UI
Adesojisouljay Jul 21, 2023
9f5c27f
style fixes
Adesojisouljay Jul 21, 2023
4b36100
style changes
Adesojisouljay Jul 21, 2023
7ef57ea
fixed empty list instance
Adesojisouljay Jul 21, 2023
bb4d180
confirm nsfw content
Adesojisouljay Jul 22, 2023
60d6768
interface types
Adesojisouljay Jul 23, 2023
8de0916
Merge branch 'development' into feat/3speak-video-upload
feruzm Jul 24, 2023
7a920d3
fix self closing
feruzm Jul 24, 2023
1d1a5b6
fix linting and remove video from comments
feruzm Jul 24, 2023
120b934
improve style
Adesojisouljay Jul 24, 2023
eb0b8a1
Merge branch 'feat/3speak-video-upload' of https://github.com/ecency/…
Adesojisouljay Jul 24, 2023
9c7f5a9
clean logs
feruzm Jul 24, 2023
4f51976
status info
Adesojisouljay Jul 24, 2023
e23bc19
Merge branch 'feat/3speak-video-upload' of https://github.com/ecency/…
Adesojisouljay Jul 24, 2023
61dc69f
remove comments
Adesojisouljay Jul 24, 2023
f5ddc47
fix syntaxes
Adesojisouljay Jul 29, 2023
48acaff
clear console
Adesojisouljay Jul 29, 2023
eed2396
move function to api/threespeak
Adesojisouljay Jul 30, 2023
fa0854d
fix modal
Adesojisouljay Jul 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
"@loadable/server": "^5.15.2",
"@tanstack/react-query": "^4.29.7",
"@tanstack/react-query-devtools": "^4.29.7",
"@types/tus-js-client": "^2.1.0",
"@webscopeio/react-textarea-autocomplete": "^4.8.1",
"axios": "^0.21.2",
"axios-cookiejar-support": "^4.0.6",
"bs58": "^4.0.1",
"connected-react-router": "^6.8.0",
"cookie-parser": "^1.4.5",
Expand All @@ -35,7 +37,7 @@
"express": "^4.17.3",
"history": "^4.7.2",
"hive-uri": "^0.2.3",
"hivesigner": "^3.2.8",
"hivesigner": "^3.3.4",
"html-react-parser": "^1.2.1",
"i18next": "^19.4.4",
"i18next-browser-languagedetector": "^4.2.0",
Expand Down Expand Up @@ -83,6 +85,8 @@
"serialize-javascript": "^3.1.0",
"sortablejs": "^1.13.0",
"speakingurl": "^14.0.1",
"tough-cookie": "^4.1.2",
"tus-js-client": "^3.1.0",
"use-async-effect": "^2.2.6",
"use-indexeddb": "^2.0.2",
"uuid": "^9.0.0",
Expand Down
3 changes: 3 additions & 0 deletions src/common/api/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import hs from "hivesigner";

import {
AccountUpdateOperation,
Authority,
CustomJsonOperation,
KeyRole,
Operation,
OperationName,
VirtualOperationName,
PrivateKey,
TransactionConfirmation
} from "@hiveio/dhive";
Expand Down
153 changes: 153 additions & 0 deletions src/common/api/threespeak.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { Memo } from "@hiveio/dhive";
import * as tus from "tus-js-client";
import axios from "axios";
import { getPostingKey } from "../helper/user-token";
import { getDecodedMemo } from "../helper/hive-signer";

const studioEndPoint = "https://studio.3speak.tv";
const tusEndPoint = "https://uploads.3speak.tv/files/";
const client = axios.create({});

export const threespeakAuth = async (username: string) => {
try {
let response = await client.get(
`${studioEndPoint}/mobile/login?username=${username}&hivesigner=true`,
{
withCredentials: false,
headers: {
"Content-Type": "application/json"
}
}
);
const memo_string = response.data.memo;
let { memoDecoded } = await getDecodedMemo(username, memo_string);

memoDecoded = memoDecoded.replace("#", "");
const user = await getTokenValidated(memoDecoded, username);
return memoDecoded;
} catch (err) {
console.log(err);
throw err;
}
};

export const getTokenValidated = async (jwt: string, username: string) => {
try {
let response = await client.get(
`${studioEndPoint}/mobile/login?username=${username}&access_token=${jwt}`,
{
withCredentials: false,
headers: {
"Content-Type": "application/json"
}
}
);
return response.data; //cookies
} catch (err) {
console.log(err);
throw err;
}
};

export const uploadVideoInfo = async (
oFilename: string,
fileSize: number,
videoUrl: string,
thumbnailUrl: string,
username: string,
duration: string
) => {
const token = await threespeakAuth(username);
try {
const { data } = await axios.post(
`${studioEndPoint}/mobile/api/upload_info?app=ecency`,
{
filename: videoUrl,
oFilename: oFilename,
size: fileSize,
duration,
thumbnail: thumbnailUrl,
isReel: false,
owner: username
},
{
withCredentials: false,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`
}
}
);
return data;
} catch (e) {
console.error(e);
throw e;
}
};

export const getAllVideoStatuses = async (username: string) => {
const token = await threespeakAuth(username);
try {
let response = await client.get(`${studioEndPoint}/mobile/api/my-videos`, {
withCredentials: false,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`
}
});
return response.data;
} catch (err) {
console.log(err);
throw err;
}
};

export const updateSpeakVideoInfo = async (
username: string,
postBody: string,
videoId: string,
title: string,
tags: string[],
isNsfwC: boolean
) => {
const token = await threespeakAuth(username);

const data = {
videoId: videoId,
title: title,
description: postBody,
isNsfwContent: isNsfwC,
tags_v2: tags
};

const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`
};

axios
.post(`${studioEndPoint}/mobile/api/update_info`, data, { headers })
.then((response) => {})
.catch((error) => {
console.error("Error:", error);
});
};

export const markAsPublished = async (username: string, videoId: string) => {
const token = await threespeakAuth(username);
const data = {
videoId
};

const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`
};

axios
.post(`${studioEndPoint}/mobile/api/my-videos/iPublished`, data, { headers })
.then((response) => {})
.catch((error) => {
console.error("Error:", error);
});
};
1 change: 1 addition & 0 deletions src/common/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Announcement from "./components/announcement";
import FloatingFAQ from "./components/floating-faq";
import { useMappedStore } from "./store/use-mapped-store";
import { EntriesCacheManager } from "./core";

import { UserActivityRecorder } from "./components/user-activity-recorder";

// Define lazy pages
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/comment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class Comment extends Component<Props, State> {
!showEmoji && !showGif && this.setState({ showEmoji: true, showGif: true })
}
>
{EditorToolbar({ ...this.props, sm: true, showEmoji })}
{EditorToolbar({ ...this.props, sm: true, showEmoji, comment: true })}
<div className="comment-body" onKeyDown={this.handleShortcuts} ref={this.commentBodyRef}>
<TextareaAutocomplete
className={`the-editor accepts-emoji ${text?.length > 20 ? "expanded" : ""}`}
Expand Down
30 changes: 27 additions & 3 deletions src/common/components/editor-toolbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, { Component, ChangeEvent } from "react";
import isEqual from "react-fast-compare";
import axios from "axios";

Expand Down Expand Up @@ -38,6 +38,7 @@ import {
textShortSvg,
gifIcon
} from "../../img/svg";
import { VideoUpload } from "../video-upload-threespeak";

interface Props {
global: Global;
Expand All @@ -46,6 +47,9 @@ interface Props {
sm?: boolean;
showEmoji?: boolean;
showGif?: boolean;
setVideoEncoderBeneficiary?: (video: any) => void;
toggleNsfwC?: () => void;
comment: boolean;
}

interface State {
Expand Down Expand Up @@ -79,6 +83,7 @@ export class EditorToolbar extends Component<Props> {

holder = React.createRef<HTMLDivElement>();
fileInput = React.createRef<HTMLInputElement>();
videoInput = React.createRef<HTMLInputElement>();

shouldComponentUpdate(nextProps: Readonly<Props>, nextState: Readonly<State>): boolean {
return (
Expand Down Expand Up @@ -477,7 +482,9 @@ export class EditorToolbar extends Component<Props> {
onClick={(e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
const el = this.fileInput.current;
if (el) el.click();
if (el) {
el.click();
}
}}
>
{_t("editor-toolbar.upload")}
Expand Down Expand Up @@ -555,6 +562,20 @@ export class EditorToolbar extends Component<Props> {
</div>
</Tooltip>
)}

{!this.props.comment && (
<Tooltip content={_t("video-upload.upload-video")}>
<div className="editor-tool" role="none">
<VideoUpload
activeUser={activeUser}
global={global}
insertText={this.insertText}
setVideoEncoderBeneficiary={this.props.setVideoEncoderBeneficiary}
toggleNsfwC={this.props.toggleNsfwC}
/>
</div>
</Tooltip>
)}
</div>
<input
onChange={this.fileInputChanged}
Expand Down Expand Up @@ -635,7 +656,10 @@ export default (props: Props) => {
activeUser: props.activeUser,
sm: props.sm,
showEmoji: props.showEmoji,
showGif: props.showGif
showGif: props.showGif,
setVideoEncoderBeneficiary: props.setVideoEncoderBeneficiary,
toggleNsfwC: props.toggleNsfwC,
comment: props.comment
};
return <EditorToolbar {...p} />;
};
Loading