Merge pull request #338 from filecoin-project/@martinalong/fix-links

fixed linking bug
This commit is contained in:
martinalong 2020-09-28 21:51:44 -07:00 committed by GitHub
commit f07889d670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -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;
} }
} }

View File

@ -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) {