mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
added music feed
This commit is contained in:
parent
8a079444b7
commit
d202a955bc
@ -1,5 +1,31 @@
|
|||||||
export default class FeedModel {
|
export default class FeedModel {
|
||||||
static async getTimelineFeed({ trim, limit }) {
|
static async getMusicFeed({ trim, limit } = {}) {
|
||||||
|
const { data } = await app.cores.api.customRequest({
|
||||||
|
method: "GET",
|
||||||
|
url: `/feed/music`,
|
||||||
|
params: {
|
||||||
|
trim: trim ?? 0,
|
||||||
|
limit: limit ?? window.app.cores.settings.get("feed_max_fetch"),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getGlobalMusicFeed({ trim, limit } = {}) {
|
||||||
|
const { data } = await app.cores.api.customRequest({
|
||||||
|
method: "GET",
|
||||||
|
url: `/feed/music/global`,
|
||||||
|
params: {
|
||||||
|
trim: trim ?? 0,
|
||||||
|
limit: limit ?? window.app.cores.settings.get("feed_max_fetch"),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getTimelineFeed({ trim, limit } = {}) {
|
||||||
const { data } = await app.cores.api.customRequest({
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/feed/timeline`,
|
url: `/feed/timeline`,
|
||||||
@ -12,7 +38,7 @@ export default class FeedModel {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getPostsFeed({ trim, limit }) {
|
static async getPostsFeed({ trim, limit } = {}) {
|
||||||
const { data } = await app.cores.api.customRequest({
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/feed/posts`,
|
url: `/feed/posts`,
|
||||||
@ -25,7 +51,7 @@ export default class FeedModel {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getPlaylistsFeed({ trim, limit }) {
|
static async getPlaylistsFeed({ trim, limit } = {}) {
|
||||||
const { data } = await app.cores.api.customRequest({
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/feed/playlists`,
|
url: `/feed/playlists`,
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
export default class PlaylistsModel {
|
export default class PlaylistsModel {
|
||||||
static get bridge() {
|
|
||||||
return window.app?.cores.api.withEndpoints()
|
|
||||||
}
|
|
||||||
|
|
||||||
static async uploadTrack(file, payload) {
|
static async uploadTrack(file, payload) {
|
||||||
if (!PlaylistsModel.bridge) {
|
|
||||||
throw new Error("Bridge is not available")
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the file from the payload
|
// get the file from the payload
|
||||||
if (!file) {
|
if (!file) {
|
||||||
throw new Error("File is required")
|
throw new Error("File is required")
|
||||||
@ -22,7 +14,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( {
|
const uploadRequest = await app.cores.api.customRequest({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/upload",
|
url: "/upload",
|
||||||
data: formData,
|
data: formData,
|
||||||
@ -38,7 +30,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( {
|
const trackRequest = await app.cores.api.customRequest({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/tracks/publish",
|
url: "/tracks/publish",
|
||||||
data: {
|
data: {
|
||||||
@ -51,7 +43,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async publishTrack(payload) {
|
static async publishTrack(payload) {
|
||||||
const { data } = await app.cores.api.customRequest( {
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/tracks/publish",
|
url: "/tracks/publish",
|
||||||
data: payload,
|
data: payload,
|
||||||
@ -61,7 +53,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async publish(payload) {
|
static async publish(payload) {
|
||||||
const { data } = await app.cores.api.customRequest( {
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `/playlist/publish`,
|
url: `/playlist/publish`,
|
||||||
data: payload,
|
data: payload,
|
||||||
@ -71,7 +63,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getPlaylist(id) {
|
static async getPlaylist(id) {
|
||||||
const { data } = await app.cores.api.customRequest( {
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/playlist/data/${id}`,
|
url: `/playlist/data/${id}`,
|
||||||
})
|
})
|
||||||
@ -80,7 +72,7 @@ export default class PlaylistsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getMyReleases() {
|
static async getMyReleases() {
|
||||||
const { data } = await app.cores.api.customRequest( {
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/playlist/self`,
|
url: `/playlist/self`,
|
||||||
})
|
})
|
||||||
@ -93,7 +85,7 @@ export default class PlaylistsModel {
|
|||||||
throw new Error("Payload is required")
|
throw new Error("Payload is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest( {
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
url: `/tracks/${payload._id}`,
|
url: `/tracks/${payload._id}`,
|
||||||
data: {
|
data: {
|
||||||
@ -109,7 +101,7 @@ export default class PlaylistsModel {
|
|||||||
throw new Error("Payload is required")
|
throw new Error("Payload is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest( {
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
url: `/playlist/${payload._id}`,
|
url: `/playlist/${payload._id}`,
|
||||||
data: {
|
data: {
|
||||||
@ -125,7 +117,7 @@ export default class PlaylistsModel {
|
|||||||
throw new Error("ID is required")
|
throw new Error("ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await app.cores.api.customRequest( {
|
const { data } = await app.cores.api.customRequest({
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
url: `/playlist/${id}`,
|
url: `/playlist/${id}`,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user