mirror of
https://github.com/ragestudio/comty.js.git
synced 2025-06-09 02:24:18 +00:00
fix spectrum model
This commit is contained in:
parent
b6280b59df
commit
ad846881fd
@ -1,96 +1,136 @@
|
|||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
import SessionService from "../session"
|
import SessionService from "../session"
|
||||||
|
//import User from "comty.js/models/user"
|
||||||
|
|
||||||
|
async function injectUserData(list) {
|
||||||
|
if (!Array.isArray(list)) {
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
const user_ids = list.map((item) => {
|
||||||
|
return item.user_id
|
||||||
|
})
|
||||||
|
|
||||||
|
//const users = await User.data(user_ids.join(","))
|
||||||
|
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
export default class Streaming {
|
export default class Streaming {
|
||||||
static apiHostname = process.env.NODE_ENV === "production" ? "https://live.ragestudio.net" : "https://fr01.ragestudio.net:8035"
|
static apiHostname = "https://live.ragestudio.net"
|
||||||
|
|
||||||
static get base() {
|
static get base() {
|
||||||
const baseInstance = axios.create({
|
const baseInstance = axios.create({
|
||||||
baseURL: Streaming.apiHostname,
|
baseURL: Streaming.apiHostname,
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
Accept: "application/json",
|
||||||
"ngrok-skip-browser-warning": "any"
|
"ngrok-skip-browser-warning": "any",
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (SessionService.token) {
|
if (SessionService.token) {
|
||||||
baseInstance.defaults.headers.common["Authorization"] = `Bearer ${SessionService.token}`
|
baseInstance.defaults.headers.common["Authorization"] =
|
||||||
}
|
`Bearer ${SessionService.token}`
|
||||||
|
}
|
||||||
|
|
||||||
return baseInstance
|
return baseInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
static async serverInfo() {
|
static async serverInfo() {
|
||||||
const { data } = await Streaming.base({
|
const { data } = await Streaming.base({
|
||||||
method: "get",
|
method: "get",
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...data,
|
...data,
|
||||||
hostname: Streaming.apiHostname
|
hostname: Streaming.apiHostname,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getOwnProfiles() {
|
static async getOwnProfiles() {
|
||||||
const { data } = await Streaming.base({
|
const { data } = await Streaming.base({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/streaming/profiles/self",
|
url: "/streaming/profiles/self",
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getProfile({ profile_id }) {
|
static async getProfile({ profile_id }) {
|
||||||
if (!profile_id) {
|
if (!profile_id) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await Streaming.base({
|
const { data } = await Streaming.base({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `/streaming/profiles/${profile_id}`,
|
url: `/streaming/profiles/${profile_id}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getStream({ profile_id }) {
|
static async getStream({ profile_id }) {
|
||||||
if (!profile_id) {
|
if (!profile_id) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await Streaming.base({
|
const { data } = await Streaming.base({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `/streaming/${profile_id}`,
|
url: `/streaming/${profile_id}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
static async deleteProfile({ profile_id }) {
|
static async deleteProfile({ profile_id }) {
|
||||||
if (!profile_id) {
|
if (!profile_id) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await Streaming.base({
|
const { data } = await Streaming.base({
|
||||||
method: "delete",
|
method: "delete",
|
||||||
url: `/streaming/profiles/${profile_id}`,
|
url: `/streaming/profiles/${profile_id}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
static async createOrUpdateStream(update) {
|
static async createOrUpdateStream(update) {
|
||||||
const { data } = await Streaming.base({
|
const { data } = await Streaming.base({
|
||||||
method: "put",
|
method: "put",
|
||||||
url: `/streaming/profiles/self`,
|
url: `/streaming/profiles/self`,
|
||||||
data: update,
|
data: update,
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getConnectionStatus({ profile_id }) {
|
static async getConnectionStatus({ profile_id }) {
|
||||||
console.warn("getConnectionStatus() | Not implemented")
|
console.warn("getConnectionStatus() | Not implemented")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getLivestreamsList({ limit, offset } = {}) {
|
||||||
|
let { data } = await Streaming.base({
|
||||||
|
method: "get",
|
||||||
|
url: "/streaming/list",
|
||||||
|
params: {
|
||||||
|
limit,
|
||||||
|
offset,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
data = await injectUserData(data)
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getLivestreamData(livestream_id) {
|
||||||
|
const { data } = await Streaming.base({
|
||||||
|
method: "get",
|
||||||
|
url: `/streaming/${livestream_id}`,
|
||||||
|
})
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user