api/v1 for chats & adding auto deploy :)
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2023-01-05 15:49:39 +01:00
parent 6ea07d4fb0
commit dd75eab9a2
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
6 changed files with 70 additions and 5 deletions

41
.drone.yml Normal file
View file

@ -0,0 +1,41 @@
kind: pipeline
type: docker
name: Deploy
clone:
disable: true
steps:
- name: Clone
image: woodpeckerci/plugin-git
settings:
recursive: true
- name: Build
depends_on:
- Clone
image: node:16
commands:
- yarn
- yarn build:prod
when:
event:
- push
- name: Execute deploy script
depends_on:
- Build
image: ubuntu:latest
environment:
SSH_KEY:
from_secret: SSH_KEY
commands:
- apt update && apt install -y openssh-client rsync
- ./ci/add-key.sh
- ./ci/deploy.sh
when:
event:
- push
branch:
- froth
- froth-akkoma

2
.gitignore vendored
View file

@ -20,3 +20,5 @@ selenium-debug.log
package-lock.json
coverage/
.dccache

17
ci/add-key.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
# only execute this script as part of the pipeline.
[ -z "$CI" ] && echo "missing ci environment variable" && exit 2
# only execute the script when github token exists.
[ -z "$SSH_KEY" ] && echo "missing ssh key" && exit 3
# write the ssh key.
mkdir /root/.ssh
echo -n "${SSH_KEY}" > /root/.ssh/id_ed25519
chmod 600 /root/.ssh/id_ed25519
# add froth.zone to our known hosts.
touch /root/.ssh/known_hosts
chmod 600 /root/.ssh/known_hosts
ssh-keyscan -H froth.zone > /etc/ssh/ssh_known_hosts 2> /dev/null

5
ci/deploy.sh Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
TARGET="pleroma@froth.zone:/opt/pleroma"
rsync --update -Pr dist/ "${TARGET}/instance/static/frontends/admin-fe/froth"

View file

@ -5,7 +5,7 @@ import { baseName } from './utils'
export async function deleteChatMessage(chat_id, message_id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/chats/${chat_id}/messages/${message_id}`,
url: `/api/v1/pleroma/admin/chats/${chat_id}/messages/${message_id}`,
method: 'delete',
headers: authHeaders(token)
})
@ -14,7 +14,7 @@ export async function deleteChatMessage(chat_id, message_id, authHost, token) {
export async function fetchChat(id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/chats/${id}`,
url: `/api/v1/pleroma/admin/chats/${id}`,
method: 'get',
headers: authHeaders(token)
})
@ -22,8 +22,8 @@ export async function fetchChat(id, authHost, token) {
export async function fetchChatMessages(id, maxId, authHost, token) {
const url = maxId
? `/api/pleroma/admin/chats/${id}/messages?max_id=${maxId}`
: `/api/pleroma/admin/chats/${id}/messages`
? `/api/v1/pleroma/admin/chats/${id}/messages?max_id=${maxId}`
: `/api/v1/pleroma/admin/chats/${id}/messages`
return await request({
baseURL: baseName(authHost),
url,

View file

@ -183,7 +183,7 @@ export async function fetchUserStatuses(id, authHost, godmode, token) {
export async function fetchUserChats(id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users/${id}/chats`,
url: `/api/v1/pleroma/admin/users/${id}/chats`,
method: 'get',
headers: authHeaders(token)
})