kopia lustrzana https://codeberg.org/nmkj/audon
add version number
rodzic
e733935406
commit
c7656fb858
|
@ -0,0 +1,2 @@
|
|||
{
|
||||
}
|
|
@ -4,12 +4,13 @@ import { RouterView } from 'vue-router'
|
|||
|
||||
<template>
|
||||
<v-app class="fill-height">
|
||||
<v-system-bar :height="40">
|
||||
<v-system-bar window>
|
||||
<v-row>
|
||||
<v-col class="text-center">
|
||||
<h2>Audon</h2>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div style="position:fixed">v0.1.0-dev</div>
|
||||
</v-system-bar>
|
||||
<v-main>
|
||||
<v-container class="fill-height">
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import HomeView from "../views/HomeView.vue";
|
||||
import LoginView from "../views/LoginView.vue";
|
||||
import CreateView from "../views/CreateView.vue";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
|
@ -15,7 +14,7 @@ const router = createRouter({
|
|||
path: "/about",
|
||||
name: "about",
|
||||
meta: {
|
||||
// noauth: true
|
||||
noauth: true
|
||||
},
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (About.[hash].js) for this route
|
||||
|
@ -33,7 +32,7 @@ const router = createRouter({
|
|||
{
|
||||
path: "/create",
|
||||
name: "create",
|
||||
component: CreateView,
|
||||
component: () => import("../views/CreateView.vue"),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
<script>
|
||||
import { mdiArrowLeft, mdiMagnify, mdiClose, mdiPlus } from "@mdi/js";
|
||||
import { useVuelidate } from "@vuelidate/core";
|
||||
import { useMastodonStore } from "../stores/mastodon"
|
||||
import { helpers, required } from "@vuelidate/validators";
|
||||
import { debounce, some, map } from "lodash-es";
|
||||
import { login } from "masto";
|
||||
import { webfinger } from "../assets/utils";
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
return {
|
||||
v$: useVuelidate(),
|
||||
donStore: useMastodonStore()
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
@ -45,6 +48,7 @@ export default {
|
|||
timeout: 5000,
|
||||
colour: "",
|
||||
},
|
||||
isSubmissionLoading: false,
|
||||
};
|
||||
},
|
||||
validations() {
|
||||
|
@ -64,6 +68,7 @@ export default {
|
|||
watch: {
|
||||
searchQuery(val) {
|
||||
this.isCandiadateLoading = false;
|
||||
this.cohostSearch.cancel();
|
||||
if (!val) return;
|
||||
if (some(this.cohosts, { finger: val })) {
|
||||
this.searchError.message = "すでに追加済みです";
|
||||
|
@ -71,6 +76,9 @@ export default {
|
|||
this.searchError.enabled = true;
|
||||
return;
|
||||
}
|
||||
if (val === this.donStore.myWebfinger) {
|
||||
return;
|
||||
}
|
||||
this.isCandiadateLoading = true;
|
||||
this.cohostSearch(val);
|
||||
},
|
||||
|
@ -85,7 +93,10 @@ export default {
|
|||
}
|
||||
try {
|
||||
const url = new URL(`https://${finger[1]}`);
|
||||
const client = await login({ url: url.toString(), disableVersionCheck: true });
|
||||
const client = await login({
|
||||
url: url.toString(),
|
||||
disableVersionCheck: true,
|
||||
});
|
||||
const user = await client.accounts.lookup({ acct: finger[0] });
|
||||
user.finger = webfinger(user);
|
||||
this.searchResult = user;
|
||||
|
@ -105,6 +116,30 @@ export default {
|
|||
this.searchQuery = "";
|
||||
},
|
||||
webfinger,
|
||||
async onSubmit() {
|
||||
const isFormCorrect = await this.v$.$validate();
|
||||
if (!isFormCorrect) {
|
||||
return;
|
||||
}
|
||||
const payload = {
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
cohosts: map(this.cohosts, (u) => ({
|
||||
remote_id: u.acct,
|
||||
remote_url: u.url,
|
||||
})),
|
||||
};
|
||||
try {
|
||||
const resp = await axios.post("/api/room", payload);
|
||||
if (resp.status === 201) {
|
||||
// TODO: redirect to the created room
|
||||
}
|
||||
} catch (error) {
|
||||
this.searchError.message = `Error: ${error}`
|
||||
this.searchError.colour = "error"
|
||||
this.searchError.enabled = true
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -123,7 +158,7 @@ export default {
|
|||
>
|
||||
{{ searchError.message }}
|
||||
</v-snackbar>
|
||||
<v-card>
|
||||
<v-card :loading="isSubmissionLoading">
|
||||
<v-card-title class="text-center">部屋を新規作成</v-card-title>
|
||||
<v-card-text>
|
||||
<v-form>
|
||||
|
@ -237,7 +272,7 @@ export default {
|
|||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn block color="indigo" variant="flat" >
|
||||
<v-btn block color="indigo" @click="onSubmit" variant="flat">
|
||||
作成
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<script>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
|
||||
</main>
|
||||
</template>
|
4
room.go
4
room.go
|
@ -83,10 +83,10 @@ func createRoomHandler(c echo.Context) error {
|
|||
room.RoomID = canonic()
|
||||
|
||||
// if cohosts are already registered, retrieve their data from DB
|
||||
for i, cohost := range room.CoHost {
|
||||
for i, cohost := range room.CoHosts {
|
||||
cohostUser, err := findUserByRemote(c.Request().Context(), cohost.RemoteID, cohost.RemoteURL)
|
||||
if err == nil {
|
||||
room.CoHost[i] = cohostUser
|
||||
room.CoHosts[i] = cohostUser
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ type (
|
|||
|
||||
Room struct {
|
||||
RoomID string `bson:"room_id" json:"room_id" validate:"required,printascii"`
|
||||
Title string `bson:"title" json:"title" validate:"required,printascii|multibyte"`
|
||||
Description string `bson:"description" json:"description" validate:"printascii|multibyte"`
|
||||
Title string `bson:"title" json:"title" validate:"required,max=100,printascii|multibyte"`
|
||||
Description string `bson:"description" json:"description" validate:"max=500,printascii|multibyte"`
|
||||
Host *AudonUser `bson:"host" json:"host"`
|
||||
CoHost []*AudonUser `bson:"cohost" json:"cohost,omitempty"`
|
||||
CoHosts []*AudonUser `bson:"cohost" json:"cohosts,omitempty"`
|
||||
FollowingOnly bool `bson:"following_only" json:"following_only"`
|
||||
FollowerOnly bool `bson:"follower_only" json:"follower_only"`
|
||||
MutualOnly bool `bson:"mutual_only" json:"mutual_only"`
|
||||
|
@ -59,7 +59,7 @@ func (r *Room) IsCoHost(u *AudonUser) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
for _, cohost := range r.CoHost {
|
||||
for _, cohost := range r.CoHosts {
|
||||
if cohost.Equal(u) {
|
||||
return true
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue