A decentralized music tracking and discovery platform built on AT Protocol 馃幍
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
1import axios from "axios";
2import type { GifEmbed } from "./klipy";
3import type { Mention } from "../lib/richtext";
4import { API_URL } from "../consts";
5
6export const shout = async (
7 uri: string,
8 message: string,
9 gif?: GifEmbed,
10 facets?: Mention[],
11) => {
12 const response = await axios.post(
13 `${API_URL}/users/${uri.replace("at://", "")}/shouts`,
14 { message, gif, facets },
15 {
16 headers: {
17 "Content-Type": "application/json",
18 Authorization: `Bearer ${localStorage.getItem("token")}`,
19 },
20 },
21 );
22 return response.data;
23};
24
25export const getShouts = async (uri: string) => {
26 const response = await axios.get(
27 `${API_URL}/users/${uri.replace("at://", "")}/shouts`,
28 {
29 headers: {
30 Authorization: `Bearer ${localStorage.getItem("token")}`,
31 },
32 },
33 );
34 return response.data;
35};
36
37export const reply = async (
38 uri: string,
39 message: string,
40 gif?: GifEmbed,
41 facets?: Mention[],
42) => {
43 const response = await axios.post(
44 `${API_URL}/users/${uri.replace("at://", "")}/replies`,
45 { message, gif, facets },
46 {
47 headers: {
48 "Content-Type": "application/json",
49 Authorization: `Bearer ${localStorage.getItem("token")}`,
50 },
51 },
52 );
53 return response.data;
54};
55
56export const getReplies = async (uri: string) => {
57 const response = await axios.get(
58 `${API_URL}/users/${uri.replace("at://", "")}/replies`,
59 );
60 return response.data;
61};
62
63export const reportShout = async (uri: string) => {
64 const response = await axios.post(
65 `${API_URL}/users/${uri.replace("at://", "")}/report`,
66 {},
67 {
68 headers: {
69 Authorization: `Bearer ${localStorage.getItem("token")}`,
70 },
71 },
72 );
73 return response.data;
74};
75
76export const deleteShout = async (uri: string) => {
77 const response = await axios.delete(
78 `${API_URL}/users/${uri.replace("at://", "")}`,
79 {
80 headers: {
81 Authorization: `Bearer ${localStorage.getItem("token")}`,
82 },
83 },
84 );
85 return response.data;
86};
87
88export const cancelReport = async (uri: string) => {
89 const response = await axios.delete(
90 `${API_URL}/users/${uri.replace("at://", "")}/report`,
91 {
92 headers: {
93 Authorization: `Bearer ${localStorage.getItem("token")}`,
94 },
95 },
96 );
97 return response.data;
98};