-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6210b6
commit c0e2a6c
Showing
18 changed files
with
266 additions
and
621 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"use server" | ||
import { connectMongo } from "@/mongodb/db"; | ||
import Feedback from "@/mongodb/models/feedback"; | ||
|
||
export const getFeedbacks = async (req) => { | ||
try { | ||
await connectMongo(); | ||
|
||
const reports = await Feedback.find(); | ||
if (!reports || reports.length === 0) { | ||
return { message: "No feedback reports found" }; | ||
} | ||
|
||
return reports; | ||
} catch (error) { | ||
console.error("Error fetching feedback reports:", error); | ||
return { message: "Failed to retrieve feedback reports. Please try again later." , status: 500}; | ||
} | ||
}; | ||
|
||
|
||
export const createFeedback = async (data) => { | ||
const { title, description, type, severity } = data; | ||
|
||
try { | ||
await connectMongo(); | ||
|
||
const newReport = await Feedback.create({ | ||
title: title, | ||
description: description, | ||
type: type, | ||
severity: severity | ||
}); | ||
|
||
return { message: "Feedback report saved successfully" , status: 201}; | ||
|
||
} catch (error) { | ||
console.error("Error saving feedback report:", error); | ||
return { message: "Failed to save feedback report. Please try again later." , status: 500 }; | ||
} | ||
}; | ||
|
||
|
||
export const deletFeedback = async (id) => { | ||
try { | ||
await connectMongo(); | ||
|
||
if (id) { | ||
const deletedReport = await Feedback.findByIdAndDelete(id); | ||
if (!deletedReport) { | ||
return { message: `Feedback report with ID ${id} not found` }; | ||
} | ||
return { message: `Feedback report with ID ${id} deleted successfully` }; | ||
} else { | ||
// If no ID is provided, delete all feedback reports | ||
const deletedCount = await Feedback.deleteMany({}); | ||
return { message: `Deleted ${deletedCount.deletedCount} feedback reports` }; | ||
} | ||
} catch (error) { | ||
console.error(`Error deleting feedback report${id ? ` with ID ${id}` : 's'}:`, error); | ||
return { message: "Failed to delete feedback report(s). Please try again later." }; | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,53 @@ | ||
"use server" | ||
import { ANIME } from "@consumet/extensions"; | ||
|
||
const gogo = new ANIME.Gogoanime(); | ||
|
||
export async function getGogoSources(id) { | ||
try { | ||
const data = await gogo.fetchEpisodeSources(id); | ||
try { | ||
const data = await gogo.fetchEpisodeSources(id); | ||
|
||
if (!data) return null; | ||
if (!data) return null; | ||
|
||
return data; | ||
} catch (error) { | ||
console.log(error); | ||
return null; | ||
} | ||
return data; | ||
} catch (error) { | ||
console.log(error); | ||
return null; | ||
} | ||
} | ||
|
||
export async function getZoroSources(id) { | ||
try { | ||
const data = await fetch(`${process.env.ZORO_API}/`); | ||
|
||
if (!data) return null; | ||
|
||
return data; | ||
} catch (error) { | ||
console.log(error); | ||
return null; | ||
} | ||
export async function getZoroSources(id, provider, episodeid, epnum, subtype) { | ||
try { | ||
let data; | ||
const API = process.env.ZORO_API; | ||
if (API) { | ||
const res = await fetch(`${API}/anime/episode-srcs?id=${episodeid}&server=vidstreaming&category=${subtype}`); | ||
data = await res.json(); | ||
} else { | ||
console.log(episodeid) | ||
const resp = await fetch(`https://anify.eltik.cc/sources?providerId=${provider}&watchId=${encodeURIComponent(episodeid)}&episodeNumber=${epnum}&id=${id}&subType=${subtype}`); | ||
data = await resp.json(); | ||
} | ||
if (!data) return null; | ||
|
||
return data; | ||
} catch (error) { | ||
console.log(error); | ||
return null; | ||
} | ||
} | ||
|
||
export async function getAnimeSources(id, provider, epid, epnum, subdub) { | ||
try { | ||
if (provider === "gogoanime") { | ||
const data = await getGogoSources(epid); | ||
return data; | ||
export async function getAnimeSources(id, provider, epid, epnum, subtype) { | ||
try { | ||
if (provider === "gogoanime") { | ||
const data = await getGogoSources(epid); | ||
return data; | ||
} | ||
if (provider === "zoro") { | ||
const data = await getZoroSources(id, provider, epid, epnum, subtype) | ||
return data; | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
return null; | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
return null; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.