mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-28 03:25:55 +03:00
Merge pull request #338 from filecoin-project/@martinalong/fix-links
fixed linking bug
This commit is contained in:
commit
f07889d670
@ -1,9 +1,23 @@
|
|||||||
import { runQuery } from "~/node_common/data/utilities";
|
import { runQuery } from "~/node_common/data/utilities";
|
||||||
|
|
||||||
export default async ({ slatename, ownerId }) => {
|
export default async ({ slatename, ownerId, username }) => {
|
||||||
return await runQuery({
|
return await runQuery({
|
||||||
label: "GET_SLATE_BY_NAME",
|
label: "GET_SLATE_BY_NAME",
|
||||||
queryFn: async (DB) => {
|
queryFn: async (DB) => {
|
||||||
|
let id = ownerId;
|
||||||
|
if (username && !ownerId) {
|
||||||
|
const user = await DB.select("*")
|
||||||
|
.from("users")
|
||||||
|
.where({ username })
|
||||||
|
.first();
|
||||||
|
|
||||||
|
if (!user || user.error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
id = user.id;
|
||||||
|
}
|
||||||
|
|
||||||
const query = await DB.select("*").from("slates").where({ slatename });
|
const query = await DB.select("*").from("slates").where({ slatename });
|
||||||
|
|
||||||
if (!query || query.error) {
|
if (!query || query.error) {
|
||||||
@ -12,7 +26,7 @@ export default async ({ slatename, ownerId }) => {
|
|||||||
|
|
||||||
let foundSlate;
|
let foundSlate;
|
||||||
for (let slate of query) {
|
for (let slate of query) {
|
||||||
if (slate.data.ownerId && slate.data.ownerId === ownerId) {
|
if (slate.data.ownerId && slate.data.ownerId === id) {
|
||||||
foundSlate = slate;
|
foundSlate = slate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ app.prepare().then(async () => {
|
|||||||
|
|
||||||
const slate = await Data.getSlateByName({
|
const slate = await Data.getSlateByName({
|
||||||
slatename: req.params.slatename,
|
slatename: req.params.slatename,
|
||||||
|
username: req.params.username,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!slate) {
|
if (!slate) {
|
||||||
@ -185,6 +186,7 @@ app.prepare().then(async () => {
|
|||||||
|
|
||||||
const slate = await Data.getSlateByName({
|
const slate = await Data.getSlateByName({
|
||||||
slatename: req.params.slatename,
|
slatename: req.params.slatename,
|
||||||
|
username: req.params.username,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!slate) {
|
if (!slate) {
|
||||||
|
Loading…
Reference in New Issue
Block a user