mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
use new api model
This commit is contained in:
parent
791ff3b089
commit
fb72644374
@ -40,7 +40,7 @@ export default {
|
|||||||
const [serverManifest, setServerManifest] = React.useState(null)
|
const [serverManifest, setServerManifest] = React.useState(null)
|
||||||
|
|
||||||
const checkServerVersion = async () => {
|
const checkServerVersion = async () => {
|
||||||
const serverManifest = await app.cores.api.customRequest("main")
|
const serverManifest = await app.cores.api.customRequest()
|
||||||
|
|
||||||
setServerManifest(serverManifest.data)
|
setServerManifest(serverManifest.data)
|
||||||
}
|
}
|
||||||
|
@ -518,19 +518,7 @@ class ComtyApp extends React.Component {
|
|||||||
const initializationTasks = [
|
const initializationTasks = [
|
||||||
async () => {
|
async () => {
|
||||||
try {
|
try {
|
||||||
// get remotes origins from config
|
await this.props.cores.ApiCore.attach()
|
||||||
const defaultRemotes = config.remotes
|
|
||||||
|
|
||||||
// get storaged remotes origins
|
|
||||||
const storedRemotes = await app.cores.settings.get("remotes") ?? {}
|
|
||||||
|
|
||||||
// mount main api bridge
|
|
||||||
await this.props.cores.ApiCore.attachBridge("main", {
|
|
||||||
origin: storedRemotes.mainApi ?? defaultRemotes.mainApi,
|
|
||||||
locked: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
await this.props.cores.ApiCore.namespaces["main"].initialize()
|
|
||||||
|
|
||||||
app.eventBus.emit("app.initialization.api_success")
|
app.eventBus.emit("app.initialization.api_success")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -71,7 +71,7 @@ export default class UserDataManager extends React.Component {
|
|||||||
loading: false,
|
loading: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
api = window.app.cores.api.withEndpoints("main")
|
api = window.app.cores.api.withEndpoints()
|
||||||
|
|
||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
if (!this.props.user && this.props.userId) {
|
if (!this.props.user && this.props.userId) {
|
||||||
|
@ -12,7 +12,7 @@ export default class UserRolesManager extends React.Component {
|
|||||||
roles: null,
|
roles: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
api = window.app.cores.api.withEndpoints("main")
|
api = window.app.cores.api.withEndpoints()
|
||||||
|
|
||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
await this.fetchRoles()
|
await this.fetchRoles()
|
||||||
|
@ -104,12 +104,13 @@ export default (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const listenEvents = () => {
|
const listenEvents = () => {
|
||||||
window.app.cores.api.namespaces["main"].listenEvent(`post.new.comment.${props.post_id}`, (comment) => {
|
app.cores.api.listenEvent(`post.new.comment.${props.post_id}`, (comment) => {
|
||||||
setComments((comments) => {
|
setComments((comments) => {
|
||||||
return [comment, ...comments]
|
return [comment, ...comments]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
window.app.cores.api.namespaces["main"].listenEvent(`post.delete.comment.${props.post_id}`, (comment_id) => {
|
|
||||||
|
app.cores.api.listenEvent(`post.delete.comment.${props.post_id}`, (comment_id) => {
|
||||||
setComments((comments) => {
|
setComments((comments) => {
|
||||||
return comments.filter((comment) => comment._id !== comment_id)
|
return comments.filter((comment) => comment._id !== comment_id)
|
||||||
})
|
})
|
||||||
@ -117,8 +118,8 @@ export default (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const unlistenEvents = () => {
|
const unlistenEvents = () => {
|
||||||
window.app.cores.api.namespaces["main"].unlistenEvent(`post.new.comment.${props.post_id}`)
|
app.cores.api.unlistenEvent(`post.new.comment.${props.post_id}`)
|
||||||
window.app.cores.api.namespaces["main"].unlistenEvent(`post.delete.comment.${props.post_id}`)
|
app.cores.api.unlistenEvent(`post.delete.comment.${props.post_id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
@ -35,12 +35,12 @@ export default (props) => {
|
|||||||
fetchConnectedFriends()
|
fetchConnectedFriends()
|
||||||
|
|
||||||
for (const [event, callback] of Object.entries(wsEvents)) {
|
for (const [event, callback] of Object.entries(wsEvents)) {
|
||||||
window.app.cores.api.namespaces["main"].listenEvent(event, callback)
|
app.cores.api.listenEvent(event, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
for (const [event, callback] of Object.entries(wsEvents)) {
|
for (const [event, callback] of Object.entries(wsEvents)) {
|
||||||
window.app.cores.api.namespaces["main"].unlistenEvent(event, callback)
|
app.cores.api.unlistenEvent(event, callback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
@ -8,7 +8,7 @@ export default React.memo((props) => {
|
|||||||
const [featuredEvents, setFeaturedEvents] = React.useState([])
|
const [featuredEvents, setFeaturedEvents] = React.useState([])
|
||||||
|
|
||||||
const fetchFeaturedEvents = React.useCallback(async () => {
|
const fetchFeaturedEvents = React.useCallback(async () => {
|
||||||
let { data } = await app.cores.api.customRequest("main", {
|
let { data } = await app.cores.api.customRequest({
|
||||||
url: "/featured_events",
|
url: "/featured_events",
|
||||||
method: "GET"
|
method: "GET"
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
@ -12,7 +12,7 @@ export default class ImageUploader extends React.Component {
|
|||||||
urlList: [],
|
urlList: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
api = window.app.cores.api.withEndpoints("main")
|
api = window.app.cores.api.withEndpoints()
|
||||||
|
|
||||||
handleChange = ({ fileList }) => {
|
handleChange = ({ fileList }) => {
|
||||||
this.setState({ fileList })
|
this.setState({ fileList })
|
||||||
|
@ -103,8 +103,7 @@ export default class PostCard extends React.Component {
|
|||||||
app.eventBus.on(`post.${this.state.data._id}.update`, this.onClickEdit)
|
app.eventBus.on(`post.${this.state.data._id}.update`, this.onClickEdit)
|
||||||
|
|
||||||
// first listen to post changes
|
// first listen to post changes
|
||||||
//window.app.cores.api.namespaces["main"].listenEvent(`post.dataUpdate.${data._id}`, onDataUpdate)
|
app.cores.api.listenEvent(`post.${this.state.data._id}.likes.update`, this.onLikesUpdate)
|
||||||
window.app.cores.api.namespaces["main"].listenEvent(`post.${this.state.data._id}.likes.update`, this.onLikesUpdate)
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
isSelf: app.cores.permissions.checkUserIdIsSelf(this.state.data.user_id),
|
isSelf: app.cores.permissions.checkUserIdIsSelf(this.state.data.user_id),
|
||||||
@ -117,8 +116,7 @@ export default class PostCard extends React.Component {
|
|||||||
app.eventBus.off(`post.${this.state.data._id}.update`, this.onClickEdit)
|
app.eventBus.off(`post.${this.state.data._id}.update`, this.onClickEdit)
|
||||||
|
|
||||||
// remove the listener
|
// remove the listener
|
||||||
//window.app.cores.api.namespaces["main"].unlistenEvent(`post.dataUpdate.${data._id}`, onDataUpdate)
|
app.cores.api.listenEvent(`post.${this.state.data._id}.likes.update`, this.onLikesUpdate)
|
||||||
window.app.cores.api.namespaces["main"].listenEvent(`post.${this.state.data._id}.likes.update`, this.onLikesUpdate)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch = (error, info) => {
|
componentDidCatch = (error, info) => {
|
||||||
|
@ -18,7 +18,7 @@ const DEFAULT_POST_POLICY = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default (props) => {
|
export default (props) => {
|
||||||
const api = window.app.cores.api.withEndpoints("main")
|
const api = window.app.cores.api.withEndpoints()
|
||||||
|
|
||||||
const creatorRef = React.useRef(null)
|
const creatorRef = React.useRef(null)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export default (props) => {
|
|||||||
|
|
||||||
formData.append("files", req.file)
|
formData.append("files", req.file)
|
||||||
|
|
||||||
const response = await window.app.cores.api.customRequest("main", {
|
const response = await window.app.cores.api.customRequest( {
|
||||||
url: "/upload",
|
url: "/upload",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: formData
|
data: formData
|
||||||
|
@ -90,7 +90,7 @@ const steps = [
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/user/username-available",
|
url: "/user/username-available",
|
||||||
params: {
|
params: {
|
||||||
@ -308,7 +308,7 @@ const steps = [
|
|||||||
const timer = setTimeout(async () => {
|
const timer = setTimeout(async () => {
|
||||||
if (!validFormat) return
|
if (!validFormat) return
|
||||||
|
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/user/email-available",
|
url: "/user/email-available",
|
||||||
params: {
|
params: {
|
||||||
|
@ -14,7 +14,7 @@ export default class UserSelector extends React.Component {
|
|||||||
searchValue: null,
|
searchValue: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
api = window.app.cores.api.withEndpoints("main")
|
api = window.app.cores.api.withEndpoints()
|
||||||
|
|
||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
this.toogleLoading(true)
|
this.toogleLoading(true)
|
||||||
|
@ -49,39 +49,54 @@ function generateWSFunctionHandler(socket, type = "listen") {
|
|||||||
|
|
||||||
export default class ApiCore extends Core {
|
export default class ApiCore extends Core {
|
||||||
static namespace = "api"
|
static namespace = "api"
|
||||||
|
static depends = ["settings"]
|
||||||
|
|
||||||
excludedExpiredExceptionURL = ["/session/regenerate"]
|
excludedExpiredExceptionURL = ["/session/regenerate"]
|
||||||
|
|
||||||
onExpiredExceptionEvent = false
|
onExpiredExceptionEvent = false
|
||||||
|
|
||||||
namespaces = Object()
|
instance = null
|
||||||
|
|
||||||
public = {
|
public = {
|
||||||
namespaces: this.namespaces,
|
instance: function () {
|
||||||
customRequest: this.customRequest,
|
return this.instance
|
||||||
request: this.request,
|
}.bind(this),
|
||||||
withEndpoints: this.withEndpoints,
|
customRequest: this.customRequest.bind(this),
|
||||||
attachBridge: this.attachBridge,
|
request: this.request.bind(this),
|
||||||
detachBridge: this.detachBridge,
|
withEndpoints: this.withEndpoints.bind(this),
|
||||||
createBridge: this.createBridge,
|
attach: this.attach.bind(this),
|
||||||
autenticateWS: this.autenticateWS,
|
createBridge: this.createBridge.bind(this),
|
||||||
|
autenticateWS: this.autenticateWS.bind(this),
|
||||||
|
listenEvent: this.listenEvent.bind(this),
|
||||||
|
unlistenEvent: this.unlistenEvent.bind(this),
|
||||||
|
}
|
||||||
|
|
||||||
|
async attach() {
|
||||||
|
// get remotes origins from config
|
||||||
|
const defaultRemotes = config.remotes
|
||||||
|
|
||||||
|
// get storaged remotes origins
|
||||||
|
const storedRemotes = await app.cores.settings.get("remotes") ?? {}
|
||||||
|
|
||||||
|
const origin = storedRemotes.mainApi ?? defaultRemotes.mainApi
|
||||||
|
|
||||||
|
this.instance = this.createBridge({
|
||||||
|
origin,
|
||||||
|
})
|
||||||
|
|
||||||
|
await this.instance.initialize()
|
||||||
|
|
||||||
|
console.debug(`[API] Attached to ${origin}`, this.instance)
|
||||||
|
|
||||||
|
return this.instance
|
||||||
}
|
}
|
||||||
|
|
||||||
async customRequest(
|
async customRequest(
|
||||||
namepace = undefined,
|
|
||||||
payload = {
|
payload = {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
...args
|
...args
|
||||||
) {
|
) {
|
||||||
if (typeof namepace === "undefined") {
|
|
||||||
throw new Error("Namespace must be defined")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof this.namespaces[namepace] === "undefined") {
|
|
||||||
throw new Error("Namespace not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof payload === "string") {
|
if (typeof payload === "string") {
|
||||||
payload = {
|
payload = {
|
||||||
url: payload,
|
url: payload,
|
||||||
@ -101,31 +116,15 @@ export default class ApiCore extends Core {
|
|||||||
console.warn("Making a request with no session token")
|
console.warn("Making a request with no session token")
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.namespaces[namepace].httpInterface(payload, ...args)
|
return await this.instance.httpInterface(payload, ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
request(namespace = "main", method, endpoint, ...args) {
|
request(method, endpoint, ...args) {
|
||||||
if (!this.namespaces[namespace]) {
|
return this.instance.endpoints[method][endpoint](...args)
|
||||||
throw new Error(`Namespace ${namespace} not found`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.namespaces[namespace].endpoints[method]) {
|
|
||||||
throw new Error(`Method ${method} not found`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.namespaces[namespace].endpoints[method][endpoint]) {
|
|
||||||
throw new Error(`Endpoint ${endpoint} not found`)
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.namespaces[namespace].endpoints[method][endpoint](...args)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
withEndpoints(namespace = "main") {
|
withEndpoints() {
|
||||||
if (!this.namespaces[namespace]) {
|
return this.instance.endpoints
|
||||||
throw new Error(`Namespace ${namespace} not found`)
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.namespaces[namespace].endpoints
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleBeforeRequest(request) {
|
async handleBeforeRequest(request) {
|
||||||
@ -149,7 +148,7 @@ export default class ApiCore extends Core {
|
|||||||
const expiredToken = await SessionModel.token
|
const expiredToken = await SessionModel.token
|
||||||
|
|
||||||
// send request to regenerate token
|
// send request to regenerate token
|
||||||
const response = await this.customRequest("main", {
|
const response = await this.customRequest({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/session/regenerate",
|
url: "/session/regenerate",
|
||||||
data: {
|
data: {
|
||||||
@ -176,14 +175,6 @@ export default class ApiCore extends Core {
|
|||||||
window.app.eventBus.emit("session.regenerated")
|
window.app.eventBus.emit("session.regenerated")
|
||||||
}
|
}
|
||||||
|
|
||||||
attachBridge(key, params) {
|
|
||||||
return this.namespaces[key] = this.createBridge(params)
|
|
||||||
}
|
|
||||||
|
|
||||||
detachBridge(key) {
|
|
||||||
return delete this.namespaces[key]
|
|
||||||
}
|
|
||||||
|
|
||||||
createBridge(params = {}) {
|
createBridge(params = {}) {
|
||||||
const getSessionContext = async () => {
|
const getSessionContext = async () => {
|
||||||
const obj = {}
|
const obj = {}
|
||||||
@ -236,51 +227,74 @@ export default class ApiCore extends Core {
|
|||||||
const bridge = new Bridge(bridgeOptions)
|
const bridge = new Bridge(bridgeOptions)
|
||||||
|
|
||||||
// handle main ws onEvents
|
// handle main ws onEvents
|
||||||
const mainWSSocket = bridge.wsInterface.sockets["main"]
|
const mainSocket = bridge.wsInterface.sockets["main"]
|
||||||
|
|
||||||
mainWSSocket.on("authenticated", () => {
|
mainSocket.on("authenticated", () => {
|
||||||
console.debug("[WS] Authenticated")
|
console.debug("[WS] Authenticated")
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWSSocket.on("authenticateFailed", (error) => {
|
mainSocket.on("authenticateFailed", (error) => {
|
||||||
console.error("[WS] Authenticate Failed", error)
|
console.error("[WS] Authenticate Failed", error)
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWSSocket.on("connect", () => {
|
mainSocket.on("connect", () => {
|
||||||
if (this.ctx.eventBus) {
|
if (this.ctx.eventBus) {
|
||||||
this.ctx.eventBus.emit(`api.ws.main.connect`)
|
this.ctx.eventBus.emit(`api.ws.main.connect`)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.autenticateWS(mainWSSocket)
|
console.debug("[WS] Connected, authenticating...")
|
||||||
|
|
||||||
|
this.autenticateWS(mainSocket)
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWSSocket.on("disconnect", (...context) => {
|
mainSocket.on("disconnect", (...context) => {
|
||||||
if (this.ctx.eventBus) {
|
if (this.ctx.eventBus) {
|
||||||
this.ctx.eventBus.emit(`api.ws.main.disconnect`, ...context)
|
this.ctx.eventBus.emit(`api.ws.main.disconnect`, ...context)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWSSocket.on("connect_error", (...context) => {
|
mainSocket.on("connect_error", (...context) => {
|
||||||
if (this.ctx.eventBus) {
|
if (this.ctx.eventBus) {
|
||||||
this.ctx.eventBus.emit(`api.ws.main.connect_error`, ...context)
|
this.ctx.eventBus.emit(`api.ws.main.connect_error`, ...context)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// generate functions
|
mainSocket.onAny((event, ...args) => {
|
||||||
bridge.listenEvent = generateWSFunctionHandler(bridge.wsInterface, "listen")
|
console.debug(`[WS] Recived Event (${event})`, ...args)
|
||||||
bridge.unlistenEvent = generateWSFunctionHandler(bridge.wsInterface, "unlisten")
|
})
|
||||||
|
|
||||||
|
// mainSocket.onAnyOutgoing((event, ...args) => {
|
||||||
|
// console.debug(`[WS] Sent Event (${event})`, ...args)
|
||||||
|
// })
|
||||||
|
|
||||||
// return bridge
|
|
||||||
return bridge
|
return bridge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listenEvent(event, callback) {
|
||||||
|
if (!this.instance.wsInterface) {
|
||||||
|
throw new Error("API is not attached")
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.instance.wsInterface.sockets["main"].on(event, callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
unlistenEvent(event, callback) {
|
||||||
|
if (!this.instance.wsInterface) {
|
||||||
|
throw new Error("API is not attached")
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.instance.wsInterface.sockets["main"].off(event, callback)
|
||||||
|
}
|
||||||
|
|
||||||
async autenticateWS(socket) {
|
async autenticateWS(socket) {
|
||||||
const token = await SessionModel.token
|
const token = await SessionModel.token
|
||||||
|
|
||||||
if (token) {
|
if (!token) {
|
||||||
socket.emit("authenticate", {
|
return console.error("Failed to authenticate WS, no token found")
|
||||||
token,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
socket.emit("authenticate", {
|
||||||
|
token,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ import SessionModel from "../session"
|
|||||||
|
|
||||||
export default class AuthModel {
|
export default class AuthModel {
|
||||||
static login = async (payload) => {
|
static login = async (payload) => {
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "/auth/login",
|
url: "/auth/login",
|
||||||
data: {
|
data: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export default class FeedModel {
|
export default class FeedModel {
|
||||||
static get bridge() {
|
static get bridge() {
|
||||||
return window.app?.cores.api.withEndpoints("main")
|
return window.app?.cores.api.withEndpoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getPostsFeed({ trim, limit }) {
|
static async getPostsFeed({ trim, limit }) {
|
||||||
@ -8,7 +8,7 @@ export default class FeedModel {
|
|||||||
throw new Error("Bridge is not available")
|
throw new Error("Bridge is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/feed/posts`,
|
url: `/feed/posts`,
|
||||||
params: {
|
params: {
|
||||||
@ -25,7 +25,7 @@ export default class FeedModel {
|
|||||||
throw new Error("Bridge is not available")
|
throw new Error("Bridge is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/feed/playlists`,
|
url: `/feed/playlists`,
|
||||||
params: {
|
params: {
|
||||||
@ -42,7 +42,7 @@ export default class FeedModel {
|
|||||||
throw new Error("Bridge is not available")
|
throw new Error("Bridge is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/search`,
|
url: `/search`,
|
||||||
params: {
|
params: {
|
||||||
|
@ -6,7 +6,7 @@ export default class FollowsModel {
|
|||||||
throw new Error("user_id is required")
|
throw new Error("user_id is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/follow/user/${user_id}`,
|
url: `/follow/user/${user_id}`,
|
||||||
})
|
})
|
||||||
@ -20,7 +20,7 @@ export default class FollowsModel {
|
|||||||
user_id = SessionModel.user_id
|
user_id = SessionModel.user_id
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/follow/user/${user_id}/followers`,
|
url: `/follow/user/${user_id}/followers`,
|
||||||
})
|
})
|
||||||
@ -33,7 +33,7 @@ export default class FollowsModel {
|
|||||||
throw new Error("user_id or username is required")
|
throw new Error("user_id or username is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/follow/user/toogle",
|
url: "/follow/user/toogle",
|
||||||
data: {
|
data: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export default class Livestream {
|
export default class Livestream {
|
||||||
static async getStreamingKey() {
|
static async getStreamingKey() {
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/tv/streaming/key`,
|
url: `/tv/streaming/key`,
|
||||||
})
|
})
|
||||||
@ -9,7 +9,7 @@ export default class Livestream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async regenerateStreamingKey() {
|
static async regenerateStreamingKey() {
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/tv/streaming/key/regenerate`,
|
url: `/tv/streaming/key/regenerate`,
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export default class Livestream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async updateLivestreamInfo(payload) {
|
static async updateLivestreamInfo(payload) {
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/tv/stream/info`,
|
url: `/tv/stream/info`,
|
||||||
data: {
|
data: {
|
||||||
@ -31,7 +31,7 @@ export default class Livestream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getCategories(key) {
|
static async getCategories(key) {
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/tv/streaming/categories`,
|
url: `/tv/streaming/categories`,
|
||||||
params: {
|
params: {
|
||||||
@ -49,7 +49,7 @@ export default class Livestream {
|
|||||||
username = app.userData.username
|
username = app.userData.username
|
||||||
}
|
}
|
||||||
|
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/tv/stream/info`,
|
url: `/tv/stream/info`,
|
||||||
params: {
|
params: {
|
||||||
@ -65,7 +65,7 @@ export default class Livestream {
|
|||||||
throw new Error("Username is required")
|
throw new Error("Username is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
let request = await app.cores.api.customRequest("main", {
|
let request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/tv/streams`,
|
url: `/tv/streams`,
|
||||||
params: {
|
params: {
|
||||||
@ -77,7 +77,7 @@ export default class Livestream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getAddresses() {
|
static async getAddresses() {
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/tv/streaming/addresses`,
|
url: `/tv/streaming/addresses`,
|
||||||
})
|
})
|
||||||
@ -86,7 +86,7 @@ export default class Livestream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getLivestreams() {
|
static async getLivestreams() {
|
||||||
const request = await app.cores.api.customRequest("main", {
|
const request = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/tv/streams`,
|
url: `/tv/streams`,
|
||||||
})
|
})
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
export class MusicModel {
|
export class MusicModel {
|
||||||
static get bridge() {
|
static get bridge() {
|
||||||
return window.app?.cores.api.withEndpoints("main")
|
return window.app?.cores.api.withEndpoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
static async createSpaceRoom() {
|
static async createSpaceRoom() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "post",
|
method: "post",
|
||||||
url: `/music/create_space_room`,
|
url: `/music/create_space_room`,
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export default class PlaylistsModel {
|
export default class PlaylistsModel {
|
||||||
static get bridge() {
|
static get bridge() {
|
||||||
return window.app?.cores.api.withEndpoints("main")
|
return window.app?.cores.api.withEndpoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
static async uploadTrack(file, payload) {
|
static async uploadTrack(file, payload) {
|
||||||
@ -22,7 +22,7 @@ export default class PlaylistsModel {
|
|||||||
formData.append("files", file)
|
formData.append("files", file)
|
||||||
|
|
||||||
// send the request
|
// send the request
|
||||||
const uploadRequest = await app.cores.api.customRequest("main", {
|
const uploadRequest = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/upload",
|
url: "/upload",
|
||||||
data: formData,
|
data: formData,
|
||||||
@ -38,7 +38,7 @@ export default class PlaylistsModel {
|
|||||||
const source = uploadRequest.data.files[0].url
|
const source = uploadRequest.data.files[0].url
|
||||||
|
|
||||||
// send the request for the track to be created
|
// send the request for the track to be created
|
||||||
const trackRequest = await app.cores.api.customRequest("main", {
|
const trackRequest = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/tracks/publish",
|
url: "/tracks/publish",
|
||||||
data: {
|
data: {
|
||||||
@ -51,7 +51,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async publishTrack(payload) {
|
static async publishTrack(payload) {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/tracks/publish",
|
url: "/tracks/publish",
|
||||||
data: payload,
|
data: payload,
|
||||||
@ -61,7 +61,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async publish(payload) {
|
static async publish(payload) {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/playlist/publish`,
|
url: `/playlist/publish`,
|
||||||
data: payload,
|
data: payload,
|
||||||
@ -71,7 +71,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getPlaylist(id) {
|
static async getPlaylist(id) {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/playlist/data/${id}`,
|
url: `/playlist/data/${id}`,
|
||||||
})
|
})
|
||||||
@ -80,7 +80,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getMyReleases() {
|
static async getMyReleases() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/playlist/self`,
|
url: `/playlist/self`,
|
||||||
})
|
})
|
||||||
@ -93,7 +93,7 @@ export default class PlaylistsModel {
|
|||||||
throw new Error("Payload is required")
|
throw new Error("Payload is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
url: `/tracks/${payload._id}`,
|
url: `/tracks/${payload._id}`,
|
||||||
data: {
|
data: {
|
||||||
@ -109,7 +109,7 @@ export default class PlaylistsModel {
|
|||||||
throw new Error("Payload is required")
|
throw new Error("Payload is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
url: `/playlist/${payload._id}`,
|
url: `/playlist/${payload._id}`,
|
||||||
data: {
|
data: {
|
||||||
@ -125,7 +125,7 @@ export default class PlaylistsModel {
|
|||||||
throw new Error("ID is required")
|
throw new Error("ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
url: `/playlist/${id}`,
|
url: `/playlist/${id}`,
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export default class Post {
|
export default class Post {
|
||||||
static get bridge() {
|
static get bridge() {
|
||||||
return window.app?.cores.api.withEndpoints("main")
|
return window.app?.cores.api.withEndpoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
static get maxPostTextLength() {
|
static get maxPostTextLength() {
|
||||||
@ -16,7 +16,7 @@ export default class Post {
|
|||||||
throw new Error("Post ID is required")
|
throw new Error("Post ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/post/${post_id}`,
|
url: `/posts/post/${post_id}`,
|
||||||
})
|
})
|
||||||
@ -29,7 +29,7 @@ export default class Post {
|
|||||||
throw new Error("Post ID is required")
|
throw new Error("Post ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/comments/post/${post_id}`,
|
url: `/comments/post/${post_id}`,
|
||||||
})
|
})
|
||||||
@ -42,7 +42,7 @@ export default class Post {
|
|||||||
throw new Error("Post ID and/or comment are required")
|
throw new Error("Post ID and/or comment are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const request = await app.cores.apies.api.customRequest("main", {
|
const request = await app.cores.apies.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/comments/post/${post_id}`,
|
url: `/comments/post/${post_id}`,
|
||||||
data: {
|
data: {
|
||||||
@ -58,7 +58,7 @@ export default class Post {
|
|||||||
throw new Error("Post ID and/or comment ID are required")
|
throw new Error("Post ID and/or comment ID are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const request = await app.cores.apies.api.customRequest("main", {
|
const request = await app.cores.apies.api.customRequest( {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
url: `/comments/post/${post_id}/${comment_id}`,
|
url: `/comments/post/${post_id}/${comment_id}`,
|
||||||
})
|
})
|
||||||
@ -71,7 +71,7 @@ export default class Post {
|
|||||||
throw new Error("Bridge is not available")
|
throw new Error("Bridge is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/explore`,
|
url: `/posts/explore`,
|
||||||
params: {
|
params: {
|
||||||
@ -88,7 +88,7 @@ export default class Post {
|
|||||||
throw new Error("Bridge is not available")
|
throw new Error("Bridge is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/saved`,
|
url: `/posts/saved`,
|
||||||
params: {
|
params: {
|
||||||
@ -110,7 +110,7 @@ export default class Post {
|
|||||||
user_id = app.userData?._id
|
user_id = app.userData?._id
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/user/${user_id}`,
|
url: `/posts/user/${user_id}`,
|
||||||
params: {
|
params: {
|
||||||
@ -131,7 +131,7 @@ export default class Post {
|
|||||||
throw new Error("Post ID is required")
|
throw new Error("Post ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/posts/${post_id}/toogle_like`,
|
url: `/posts/${post_id}/toogle_like`,
|
||||||
})
|
})
|
||||||
@ -148,7 +148,7 @@ export default class Post {
|
|||||||
throw new Error("Post ID is required")
|
throw new Error("Post ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/posts/${post_id}/toogle_save`,
|
url: `/posts/${post_id}/toogle_save`,
|
||||||
})
|
})
|
||||||
@ -161,7 +161,7 @@ export default class Post {
|
|||||||
throw new Error("Bridge is not available")
|
throw new Error("Bridge is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/posts/new`,
|
url: `/posts/new`,
|
||||||
data: payload,
|
data: payload,
|
||||||
@ -179,7 +179,7 @@ export default class Post {
|
|||||||
throw new Error("Post ID is required")
|
throw new Error("Post ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
url: `/posts/${post_id}`,
|
url: `/posts/${post_id}`,
|
||||||
})
|
})
|
||||||
|
@ -28,7 +28,7 @@ export default class Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getAllSessions() {
|
static async getAllSessions() {
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/session/all"
|
url: "/session/all"
|
||||||
})
|
})
|
||||||
@ -37,7 +37,7 @@ export default class Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getCurrentSession() {
|
static async getCurrentSession() {
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/session/current"
|
url: "/session/current"
|
||||||
})
|
})
|
||||||
@ -48,7 +48,7 @@ export default class Session {
|
|||||||
static async getTokenValidation() {
|
static async getTokenValidation() {
|
||||||
const session = await Session.token
|
const session = await Session.token
|
||||||
|
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/session/validate",
|
url: "/session/validate",
|
||||||
data: {
|
data: {
|
||||||
@ -71,7 +71,7 @@ export default class Session {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "delete",
|
method: "delete",
|
||||||
url: "/session/current"
|
url: "/session/current"
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@ -94,7 +94,7 @@ export default class Session {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "delete",
|
method: "delete",
|
||||||
url: "/session/all"
|
url: "/session/all"
|
||||||
})
|
})
|
||||||
|
@ -28,7 +28,7 @@ export default class SpotifySyncModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async get_client_id() {
|
static async get_client_id() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/sync/spotify/client_id`,
|
url: `/sync/spotify/client_id`,
|
||||||
})
|
})
|
||||||
@ -37,7 +37,7 @@ export default class SpotifySyncModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async syncAuthCode(code) {
|
static async syncAuthCode(code) {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/sync/spotify/auth`,
|
url: `/sync/spotify/auth`,
|
||||||
data: {
|
data: {
|
||||||
@ -50,7 +50,7 @@ export default class SpotifySyncModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async unlinkAccount() {
|
static async unlinkAccount() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/sync/spotify/unlink`,
|
url: `/sync/spotify/unlink`,
|
||||||
})
|
})
|
||||||
@ -59,7 +59,7 @@ export default class SpotifySyncModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async isAuthorized() {
|
static async isAuthorized() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/sync/spotify/is_authorized`,
|
url: `/sync/spotify/is_authorized`,
|
||||||
})
|
})
|
||||||
@ -68,7 +68,7 @@ export default class SpotifySyncModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getData() {
|
static async getData() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/sync/spotify/data`,
|
url: `/sync/spotify/data`,
|
||||||
})
|
})
|
||||||
@ -77,7 +77,7 @@ export default class SpotifySyncModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getCurrentPlaying() {
|
static async getCurrentPlaying() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/sync/spotify/currently_playing`,
|
url: `/sync/spotify/currently_playing`,
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,7 @@ import SpotifySyncModel from "./cores/spotifyCore"
|
|||||||
|
|
||||||
export default class SyncModel {
|
export default class SyncModel {
|
||||||
static get bridge() {
|
static get bridge() {
|
||||||
return window.app?.cores.api.withEndpoints("main")
|
return window.app?.cores.api.withEndpoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
static get spotifyCore() {
|
static get spotifyCore() {
|
||||||
|
@ -12,7 +12,7 @@ export default class UploadModel {
|
|||||||
formData.append("files", file)
|
formData.append("files", file)
|
||||||
|
|
||||||
// send the request
|
// send the request
|
||||||
const uploadRequest = await app.cores.api.customRequest("main", {
|
const uploadRequest = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/upload",
|
url: "/upload",
|
||||||
data: formData,
|
data: formData,
|
||||||
|
@ -13,7 +13,7 @@ export default class User {
|
|||||||
|
|
||||||
if (username && !user_id) {
|
if (username && !user_id) {
|
||||||
// resolve user_id from username
|
// resolve user_id from username
|
||||||
const resolveResponse = await app.cores.api.customRequest("main", {
|
const resolveResponse = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/user/user_id/${username}`,
|
url: `/user/user_id/${username}`,
|
||||||
})
|
})
|
||||||
@ -21,7 +21,7 @@ export default class User {
|
|||||||
user_id = resolveResponse.data.user_id
|
user_id = resolveResponse.data.user_id
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/user/${user_id}/data`,
|
url: `/user/${user_id}/data`,
|
||||||
})
|
})
|
||||||
@ -30,7 +30,7 @@ export default class User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async updateData(payload) {
|
static async updateData(payload) {
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/user/self/update_data",
|
url: "/user/self/update_data",
|
||||||
data: {
|
data: {
|
||||||
@ -42,7 +42,7 @@ export default class User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async unsetFullName() {
|
static async unsetFullName() {
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
url: "/user/self/public_name",
|
url: "/user/self/public_name",
|
||||||
})
|
})
|
||||||
@ -51,7 +51,7 @@ export default class User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async selfRoles() {
|
static async selfRoles() {
|
||||||
const response = await app.cores.api.customRequest("main", {
|
const response = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/roles/self",
|
url: "/roles/self",
|
||||||
})
|
})
|
||||||
@ -78,7 +78,7 @@ export default class User {
|
|||||||
user_id = SessionModel.user_id
|
user_id = SessionModel.user_id
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/badge/user/${user_id}`,
|
url: `/badge/user/${user_id}`,
|
||||||
})
|
})
|
||||||
@ -89,7 +89,7 @@ export default class User {
|
|||||||
static async changePassword(payload) {
|
static async changePassword(payload) {
|
||||||
const { currentPassword, newPassword } = payload
|
const { currentPassword, newPassword } = payload
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/self/update_password",
|
url: "/self/update_password",
|
||||||
data: {
|
data: {
|
||||||
@ -111,7 +111,7 @@ export default class User {
|
|||||||
user_id = SessionModel.user_id
|
user_id = SessionModel.user_id
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/user/${user_id}/followers`,
|
url: `/user/${user_id}/followers`,
|
||||||
params: {
|
params: {
|
||||||
@ -124,7 +124,7 @@ export default class User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getConnectedUsersFollowing() {
|
static async getConnectedUsersFollowing() {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/status/connected/following",
|
url: "/status/connected/following",
|
||||||
})
|
})
|
||||||
|
@ -74,7 +74,7 @@ export default class Account extends React.Component {
|
|||||||
|
|
||||||
actionsRef = React.createRef()
|
actionsRef = React.createRef()
|
||||||
|
|
||||||
api = window.app.cores.api.withEndpoints("main")
|
api = window.app.cores.api.withEndpoints()
|
||||||
|
|
||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
const token = await SessionModel.getDecodedToken()
|
const token = await SessionModel.getDecodedToken()
|
||||||
|
@ -24,7 +24,7 @@ export default (props) => {
|
|||||||
const [eventData, setEventData] = React.useState(null)
|
const [eventData, setEventData] = React.useState(null)
|
||||||
|
|
||||||
const fetchEventData = async () => {
|
const fetchEventData = async () => {
|
||||||
const { data } = await app.cores.api.customRequest("main", {
|
const { data } = await app.cores.api.customRequest( {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/featured_event/${eventId}`
|
url: `/featured_event/${eventId}`
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
@ -33,7 +33,7 @@ export default (props) => {
|
|||||||
const [wallpaperData, setWallpaperData] = React.useState(null)
|
const [wallpaperData, setWallpaperData] = React.useState(null)
|
||||||
|
|
||||||
const setRandomWallpaper = async () => {
|
const setRandomWallpaper = async () => {
|
||||||
const featuredWallpapers = await app.cores.api.request("main", "get", "featuredWallpapers").catch((err) => {
|
const featuredWallpapers = await app.cores.api.request("get", "featuredWallpapers").catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
|
@ -92,13 +92,13 @@ export default class ExplorePosts extends React.Component {
|
|||||||
await this.loadPosts()
|
await this.loadPosts()
|
||||||
|
|
||||||
Object.keys(this.wsEvents).forEach((event) => {
|
Object.keys(this.wsEvents).forEach((event) => {
|
||||||
window.app.cores.api.namespaces["main"].listenEvent(event, this.wsEvents[event])
|
app.cores.api.listenEvent(event, this.wsEvents[event])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount = async () => {
|
componentWillUnmount = async () => {
|
||||||
Object.keys(this.wsEvents).forEach((event) => {
|
Object.keys(this.wsEvents).forEach((event) => {
|
||||||
window.app.cores.api.namespaces["main"].unlistenEvent(event, this.wsEvents[event])
|
app.cores.api.unlistenEvent(event, this.wsEvents[event])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ export default class Feed extends React.Component {
|
|||||||
console.log(this.wsEvents)
|
console.log(this.wsEvents)
|
||||||
|
|
||||||
Object.keys(this.wsEvents).forEach((event) => {
|
Object.keys(this.wsEvents).forEach((event) => {
|
||||||
window.app.cores.api.namespaces["main"].listenEvent(event, this.wsEvents[event])
|
app.cores.api.listenEvent(event, this.wsEvents[event])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount = async () => {
|
componentWillUnmount = async () => {
|
||||||
Object.keys(this.wsEvents).forEach((event) => {
|
Object.keys(this.wsEvents).forEach((event) => {
|
||||||
window.app.cores.api.namespaces["main"].unlistenEvent(event, this.wsEvents[event])
|
app.cores.api.unlistenEvent(event, this.wsEvents[event])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user