mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-24 17:44:50 +03:00
Merge pull request #177 from filecoin-project/@jimmylee/updates
@jimmylee/updates
This commit is contained in:
commit
2fb22bdc41
@ -53,7 +53,7 @@ export const getSelectedState = (props) => {
|
||||
|
||||
return {
|
||||
address: null,
|
||||
// address: info.defaultStorageConfig.cold.filecoin.addr,
|
||||
address: info.defaultStorageConfig.cold.filecoin.addr,
|
||||
};
|
||||
};
|
||||
|
||||
@ -62,6 +62,14 @@ export const getInitialState = (props) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { ...props };
|
||||
};
|
||||
|
||||
export const _deprecated_getInitialState = (props) => {
|
||||
if (!props) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
id,
|
||||
status,
|
||||
@ -89,20 +97,28 @@ export const getInitialState = (props) => {
|
||||
settings_deals_auto_approve: settings.deals_auto_approve,
|
||||
|
||||
// NOTE(jim): Powergate Hot Settings
|
||||
// settings_hot_enabled: info.defaultStorageConfig.hot.enabled,
|
||||
// settings_hot_allow_unfreeze: info.defaultStorageConfig.hot.allowUnfreeze,
|
||||
// settings_hot_ipfs_add_timeout: info.defaultStorageConfig.hot.ipfs.addTimeout,
|
||||
settings_hot_enabled: info.defaultStorageConfig.hot.enabled,
|
||||
settings_hot_allow_unfreeze: info.defaultStorageConfig.hot.allowUnfreeze,
|
||||
settings_hot_ipfs_add_timeout:
|
||||
info.defaultStorageConfig.hot.ipfs.addTimeout,
|
||||
|
||||
// NOTE(jim): Powergate Cold Settings
|
||||
// settings_cold_enabled: info.defaultStorageConfig.cold.enabled,
|
||||
// settings_cold_default_address: info.defaultStorageConfig.cold.filecoin.addr,
|
||||
// settings_cold_default_duration: info.defaultStorageConfig.cold.filecoin.dealMinDuration,
|
||||
// settings_cold_default_replication_factor: info.defaultStorageConfig.cold.filecoin.repFactor,
|
||||
// settings_cold_default_excluded_miners: info.defaultStorageConfig.cold.filecoin.excludedMinersList,
|
||||
// settings_cold_default_trusted_miners: info.defaultStorageConfig.cold.filecoin.trustedMinersList,
|
||||
// settings_cold_default_max_price: info.defaultStorageConfig.cold.filecoin.maxPrice,
|
||||
// settings_cold_default_auto_renew: info.defaultStorageConfig.cold.filecoin.renew.enabled,
|
||||
// settings_cold_default_auto_renew_max_price: info.defaultStorageConfig.cold.filecoin.renew.threshold,
|
||||
settings_cold_enabled: info.defaultStorageConfig.cold.enabled,
|
||||
settings_cold_default_address: info.defaultStorageConfig.cold.filecoin.addr,
|
||||
settings_cold_default_duration:
|
||||
info.defaultStorageConfig.cold.filecoin.dealMinDuration,
|
||||
settings_cold_default_replication_factor:
|
||||
info.defaultStorageConfig.cold.filecoin.repFactor,
|
||||
settings_cold_default_excluded_miners:
|
||||
info.defaultStorageConfig.cold.filecoin.excludedMinersList,
|
||||
settings_cold_default_trusted_miners:
|
||||
info.defaultStorageConfig.cold.filecoin.trustedMinersList,
|
||||
settings_cold_default_max_price:
|
||||
info.defaultStorageConfig.cold.filecoin.maxPrice,
|
||||
settings_cold_default_auto_renew:
|
||||
info.defaultStorageConfig.cold.filecoin.renew.enabled,
|
||||
settings_cold_default_auto_renew_max_price:
|
||||
info.defaultStorageConfig.cold.filecoin.renew.threshold,
|
||||
|
||||
storageList,
|
||||
retrievalList,
|
||||
@ -110,7 +126,7 @@ export const getInitialState = (props) => {
|
||||
keys,
|
||||
stats,
|
||||
library,
|
||||
// peers: transformPeers(peersList),
|
||||
// addresses: transformAddresses(addrsList, info),
|
||||
peers: transformPeers(peersList),
|
||||
addresses: transformAddresses(addrsList, info),
|
||||
};
|
||||
};
|
||||
|
@ -72,8 +72,8 @@ const SCENES = {
|
||||
|
||||
export default class ApplicationPage extends React.Component {
|
||||
state = {
|
||||
selected: State.getSelectedState(this.props.viewer),
|
||||
viewer: State.getInitialState(this.props.viewer),
|
||||
selected: {},
|
||||
viewer: this.props.viewer,
|
||||
history: [{ id: "V1_NAVIGATION_HOME", scrollTop: 0, data: null }],
|
||||
currentIndex: 0,
|
||||
data: null,
|
||||
@ -120,7 +120,11 @@ export default class ApplicationPage extends React.Component {
|
||||
}
|
||||
|
||||
// NOTE(jim): Only allow the sidebar to show with file drag and drop.
|
||||
if (e.dataTransfer.items && e.dataTransfer.items.length && e.dataTransfer.items[0].kind !== "file") {
|
||||
if (
|
||||
e.dataTransfer.items &&
|
||||
e.dataTransfer.items.length &&
|
||||
e.dataTransfer.items[0].kind !== "file"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -274,7 +278,8 @@ export default class ApplicationPage extends React.Component {
|
||||
_handleDeleteYourself = async () => {
|
||||
// TODO(jim):
|
||||
// Put this somewhere better for messages.
|
||||
const message = "Do you really want to delete your account? It will be permanently removed";
|
||||
const message =
|
||||
"Do you really want to delete your account? It will be permanently removed";
|
||||
if (!window.confirm(message)) {
|
||||
return false;
|
||||
}
|
||||
@ -445,8 +450,12 @@ export default class ApplicationPage extends React.Component {
|
||||
<WebsitePrototypeWrapper
|
||||
title="Slate: sign in"
|
||||
description="Sign in to your Slate account to manage your assets."
|
||||
url="https://slate.host/_">
|
||||
<SceneSignIn onAuthenticate={this._handleAuthenticate} onNavigateTo={this._handleNavigateTo} />
|
||||
url="https://slate.host/_"
|
||||
>
|
||||
<SceneSignIn
|
||||
onAuthenticate={this._handleAuthenticate}
|
||||
onNavigateTo={this._handleNavigateTo}
|
||||
/>
|
||||
</WebsitePrototypeWrapper>
|
||||
);
|
||||
}
|
||||
@ -519,12 +528,17 @@ export default class ApplicationPage extends React.Component {
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<WebsitePrototypeWrapper description={description} title={title} url={url}>
|
||||
<WebsitePrototypeWrapper
|
||||
description={description}
|
||||
title={title}
|
||||
url={url}
|
||||
>
|
||||
<ApplicationLayout
|
||||
header={headerElement}
|
||||
navigation={navigationElement}
|
||||
sidebar={sidebarElement}
|
||||
onDismissSidebar={this._handleDismissSidebar}>
|
||||
onDismissSidebar={this._handleDismissSidebar}
|
||||
>
|
||||
{scene}
|
||||
</ApplicationLayout>
|
||||
<System.GlobalCarousel />
|
||||
|
@ -30,9 +30,10 @@ const STYLES_CONTAINER = css`
|
||||
`;
|
||||
|
||||
const STYLES_ACTIONS = css`
|
||||
z-index: ${Constants.zindex.navigation};
|
||||
bottom: 16px;
|
||||
right: 8px;
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
`;
|
||||
@ -137,7 +138,10 @@ export default class Slate extends React.Component {
|
||||
return (
|
||||
<div key={index} css={STYLES_ITEM}>
|
||||
<SlateMediaObjectPreview type={data.type} url={data.url} />
|
||||
<figure css={STYLES_BUTTON} onClick={() => this.props.onSelect(index)}>
|
||||
<figure
|
||||
css={STYLES_BUTTON}
|
||||
onClick={() => this.props.onSelect(index)}
|
||||
>
|
||||
<CircleButtonLight>
|
||||
<SVG.Eye height="16px" />
|
||||
</CircleButtonLight>
|
||||
@ -173,7 +177,8 @@ export default class Slate extends React.Component {
|
||||
useCSSTransforms={false}
|
||||
compactType={this.state.compactType}
|
||||
preventCollision={false}
|
||||
margin={[24, 24]}>
|
||||
margin={[24, 24]}
|
||||
>
|
||||
{this.generateDOM()}
|
||||
</ResponsiveReactGridLayout>
|
||||
{this.props.editing ? (
|
||||
@ -181,11 +186,18 @@ export default class Slate extends React.Component {
|
||||
<span css={STYLES_ACTION_BUTTON} onClick={this._handleResetLayout}>
|
||||
Reset Layout
|
||||
</span>
|
||||
<span css={STYLES_ACTION_BUTTON} onClick={this._handleSaveLayout}>
|
||||
<span
|
||||
css={STYLES_ACTION_BUTTON}
|
||||
onClick={this._handleSaveLayout}
|
||||
style={{
|
||||
backgroundColor:
|
||||
this.state.saving === "IDLE" ? Constants.system.brand : null,
|
||||
}}
|
||||
>
|
||||
{this.state.saving === "SAVING" ? (
|
||||
<LoaderSpinner style={{ height: 16, width: 16 }} />
|
||||
) : this.state.saving === "IDLE" ? (
|
||||
"Save Layout"
|
||||
"Save"
|
||||
) : (
|
||||
"Saved"
|
||||
)}
|
||||
|
@ -4,14 +4,17 @@ export default async ({ key }) => {
|
||||
return await runQuery({
|
||||
label: "GET_API_KEY_BY_KEY",
|
||||
queryFn: async (DB) => {
|
||||
const query = await DB.select("*").from("keys").where({ key }).first();
|
||||
const query = await DB.select("*")
|
||||
.from("keys")
|
||||
.where({ key })
|
||||
.first();
|
||||
|
||||
if (!query || query.error) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (query.id) {
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -14,7 +14,7 @@ export default async ({ id }) => {
|
||||
}
|
||||
|
||||
if (query.id) {
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -12,7 +12,7 @@ export default async ({ userId }) => {
|
||||
return [];
|
||||
}
|
||||
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
},
|
||||
errorFn: async (e) => {
|
||||
return {
|
||||
|
@ -14,7 +14,7 @@ export default async ({ id }) => {
|
||||
}
|
||||
|
||||
if (query.id) {
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -14,7 +14,7 @@ export default async ({ slatename }) => {
|
||||
}
|
||||
|
||||
if (query.id) {
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -4,21 +4,28 @@ export default async ({ userId, publicOnly = false }) => {
|
||||
return await runQuery({
|
||||
label: "GET_SLATES_BY_USER_ID",
|
||||
queryFn: async (DB) => {
|
||||
const hasUser = (id) => DB.raw(`?? @> ?::jsonb`, ["data", JSON.stringify({ ownerId: id })]);
|
||||
const isPublic = () => DB.raw(`?? @> ?::jsonb`, ["data", JSON.stringify({ public: true })]);
|
||||
const hasUser = (id) =>
|
||||
DB.raw(`?? @> ?::jsonb`, ["data", JSON.stringify({ ownerId: id })]);
|
||||
const isPublic = () =>
|
||||
DB.raw(`?? @> ?::jsonb`, ["data", JSON.stringify({ public: true })]);
|
||||
|
||||
let query;
|
||||
if (publicOnly) {
|
||||
query = await DB.select("*").from("slates").where(hasUser(userId)).where(isPublic());
|
||||
query = await DB.select("*")
|
||||
.from("slates")
|
||||
.where(hasUser(userId))
|
||||
.where(isPublic());
|
||||
} else {
|
||||
query = await DB.select("*").from("slates").where(hasUser(userId));
|
||||
query = await DB.select("*")
|
||||
.from("slates")
|
||||
.where(hasUser(userId));
|
||||
}
|
||||
|
||||
if (!query || query.error) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
},
|
||||
errorFn: async (e) => {
|
||||
return {
|
||||
|
@ -14,7 +14,7 @@ export default async ({ id }) => {
|
||||
}
|
||||
|
||||
if (query.id) {
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -14,7 +14,7 @@ export default async ({ username }) => {
|
||||
}
|
||||
|
||||
if (query.id) {
|
||||
return query;
|
||||
return JSON.parse(JSON.stringify(query));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -17,11 +17,8 @@ export const getById = async ({ id }) => {
|
||||
}
|
||||
|
||||
let data = null;
|
||||
const response = await Data.getSlatesByUserId({ userId: id });
|
||||
const slates = JSON.parse(JSON.stringify(response));
|
||||
|
||||
const keysRaw = await Data.getAPIKeysByUserId({ userId: id });
|
||||
const keys = JSON.parse(JSON.stringify(keysRaw));
|
||||
const slates = await Data.getSlatesByUserId({ userId: id });
|
||||
const keys = await Data.getAPIKeysByUserId({ userId: id });
|
||||
|
||||
let bytes = 0;
|
||||
user.data.library[0].children.forEach((each) => {
|
||||
@ -31,7 +28,11 @@ export const getById = async ({ id }) => {
|
||||
try {
|
||||
data = {
|
||||
id: user.id,
|
||||
data: { photo: user.data.photo, body: user.data.body ? user.data.body : "" },
|
||||
data: {
|
||||
photo: user.data.photo,
|
||||
name: user.data.name ? user.data.name : user.username,
|
||||
body: user.data.body ? user.data.body : "",
|
||||
},
|
||||
settings: {
|
||||
deals_auto_approve: user.data.settings_deals_auto_approve,
|
||||
},
|
||||
@ -50,17 +51,6 @@ export const getById = async ({ id }) => {
|
||||
addrsList: null,
|
||||
info: null,
|
||||
};
|
||||
|
||||
// TODO(jim): Disables Powergate Features
|
||||
/*
|
||||
const updates = await Utilities.refresh(user);
|
||||
const updatesWithToken = await Utilities.refreshWithToken(user);
|
||||
|
||||
data = await Utilities.updateStateData(data, {
|
||||
...updates,
|
||||
...updatesWithToken,
|
||||
});
|
||||
*/
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return null;
|
||||
|
@ -98,7 +98,9 @@ export default class SlatePage extends React.Component {
|
||||
return {
|
||||
id: each.id,
|
||||
data: each,
|
||||
component: <SlateMediaObject key={each.id} useImageFallback data={each} />,
|
||||
component: (
|
||||
<SlateMediaObject key={each.id} useImageFallback data={each} />
|
||||
),
|
||||
};
|
||||
}),
|
||||
},
|
||||
@ -112,8 +114,10 @@ export default class SlatePage extends React.Component {
|
||||
});
|
||||
|
||||
render() {
|
||||
const title = `${this.props.slate.ownername}/${this.props.slate.slatename}`;
|
||||
const url = `https://slate.host/${this.props.slate.ownername}`;
|
||||
const title = `${this.props.creator.username}/${
|
||||
this.props.slate.slatename
|
||||
}`;
|
||||
const url = `https://slate.host/${this.props.creator.username}`;
|
||||
const description = this.props.slate.data.body;
|
||||
|
||||
let image;
|
||||
@ -124,12 +128,17 @@ export default class SlatePage extends React.Component {
|
||||
});
|
||||
|
||||
return (
|
||||
<WebsitePrototypeWrapper title={title} description={description} url={url} image={image}>
|
||||
<WebsitePrototypeWrapper
|
||||
title={title}
|
||||
description={description}
|
||||
url={url}
|
||||
image={image}
|
||||
>
|
||||
<div css={STYLES_ROOT}>
|
||||
<WebsitePrototypeHeaderGeneric href={url}>
|
||||
<div css={STYLES_HEADER}>
|
||||
<div css={STYLES_HEADER_LEFT}>
|
||||
{this.props.slate.ownername} / {this.props.slate.slatename}
|
||||
{this.props.creator.username} / {this.props.slate.slatename}
|
||||
</div>
|
||||
<div css={STYLES_HEADER_RIGHT}>{this.props.slate.data.body}</div>
|
||||
</div>
|
||||
|
@ -3,7 +3,6 @@ import * as MW from "~/node_common/middleware";
|
||||
import * as Data from "~/node_common/data";
|
||||
import * as Utilities from "~/node_common/utilities";
|
||||
import * as Validations from "~/common/validations";
|
||||
import * as Powergate from "~/node_common/powergate";
|
||||
|
||||
import BCrypt from "bcrypt";
|
||||
|
||||
@ -16,7 +15,9 @@ export default async (req, res) => {
|
||||
|
||||
const id = Utilities.getIdFromCookie(req);
|
||||
if (!id) {
|
||||
return res.status(500).json({ decorator: "SERVER_USER_UPDATE", error: true });
|
||||
return res
|
||||
.status(500)
|
||||
.json({ decorator: "SERVER_USER_UPDATE", error: true });
|
||||
}
|
||||
|
||||
const user = await Data.getUserById({
|
||||
@ -24,14 +25,18 @@ export default async (req, res) => {
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
return res.status(404).json({ decorator: "SERVER_USER_UPDATE_USER_NOT_FOUND", error: true });
|
||||
return res
|
||||
.status(404)
|
||||
.json({ decorator: "SERVER_USER_UPDATE_USER_NOT_FOUND", error: true });
|
||||
}
|
||||
|
||||
if (user.error) {
|
||||
return res.status(500).json({ decorator: "SERVER_USER_UPDATE_USER_NOT_FOUND", error: true });
|
||||
return res
|
||||
.status(500)
|
||||
.json({ decorator: "SERVER_USER_UPDATE_USER_NOT_FOUND", error: true });
|
||||
}
|
||||
|
||||
const PG = Powergate.get(user);
|
||||
// const PG = Powergate.get(user);
|
||||
|
||||
if (req.body.data) {
|
||||
const response = await Data.updateUserById({
|
||||
@ -57,7 +62,9 @@ export default async (req, res) => {
|
||||
// in OSS, add a random value as an environment variable.
|
||||
if (req.body.type == "CHANGE_PASSWORD") {
|
||||
if (!Validations.password(req.body.password)) {
|
||||
return res.status(500).json({ decorator: "SERVER_INVALID_PASSWORD", error: true });
|
||||
return res
|
||||
.status(500)
|
||||
.json({ decorator: "SERVER_INVALID_PASSWORD", error: true });
|
||||
}
|
||||
|
||||
const rounds = Number(Environment.LOCAL_PASSWORD_ROUNDS);
|
||||
@ -73,6 +80,7 @@ export default async (req, res) => {
|
||||
|
||||
// TODO(jim): POWERGATE_ISSUE 0.2.0
|
||||
// Should work when our hosted Powergate works.
|
||||
/*
|
||||
if (req.body.type === "SET_DEFAULT_STORAGE_CONFIG") {
|
||||
let data;
|
||||
try {
|
||||
@ -82,9 +90,11 @@ export default async (req, res) => {
|
||||
return res.status(500).send({ decorator: "SERVER_USER_UPDATE_SETTINGS_CONFIG", error: true });
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO(jim): POWERGATE_ISSUE 0.2.0
|
||||
// Should work when our hosted Powergate works.
|
||||
/*
|
||||
if (req.body.type === "CREATE_FILECOIN_ADDRESS") {
|
||||
let data;
|
||||
try {
|
||||
@ -93,6 +103,7 @@ export default async (req, res) => {
|
||||
return res.status(500).send({ decorator: "SERVER_CREATE_FILECOIN_ADDRESS", error: true });
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return res.status(200).json({ decorator: "SERVER_USER_UPDATE" });
|
||||
};
|
||||
|
@ -33,6 +33,7 @@ export default class SceneEditAccount extends React.Component {
|
||||
confirm: "",
|
||||
body: this.props.viewer.data.body,
|
||||
photo: this.props.viewer.data.photo,
|
||||
name: this.props.viewer.data.name,
|
||||
deleting: false,
|
||||
changingPassword: false,
|
||||
changingUsername: false,
|
||||
@ -66,6 +67,7 @@ export default class SceneEditAccount extends React.Component {
|
||||
data: {
|
||||
photo: `https://hub.textile.io${json.data.ipfs}`,
|
||||
body: this.state.body,
|
||||
name: this.state.name,
|
||||
},
|
||||
});
|
||||
|
||||
@ -81,6 +83,7 @@ export default class SceneEditAccount extends React.Component {
|
||||
data: {
|
||||
photo: this.state.photo,
|
||||
body: this.state.body,
|
||||
name: this.state.name,
|
||||
},
|
||||
});
|
||||
|
||||
@ -102,6 +105,7 @@ export default class SceneEditAccount extends React.Component {
|
||||
data: {
|
||||
photo: this.state.photo,
|
||||
body: this.state.body,
|
||||
name: this.state.name,
|
||||
},
|
||||
});
|
||||
|
||||
@ -188,8 +192,8 @@ export default class SceneEditAccount extends React.Component {
|
||||
label="Username"
|
||||
description={
|
||||
<React.Fragment>
|
||||
This is your username on Slate. Your username is used for your
|
||||
profile URL{" "}
|
||||
This is your username on Slate. Your username is unique and used
|
||||
for your profile URL{" "}
|
||||
<a href={profileURL} target="_blank">
|
||||
{profileURL}
|
||||
</a>
|
||||
@ -197,7 +201,7 @@ export default class SceneEditAccount extends React.Component {
|
||||
}
|
||||
name="username"
|
||||
value={this.state.username}
|
||||
placeholder="Name"
|
||||
placeholder="Username"
|
||||
onChange={this._handleChange}
|
||||
/>
|
||||
|
||||
@ -210,7 +214,17 @@ export default class SceneEditAccount extends React.Component {
|
||||
</System.ButtonPrimary>
|
||||
</div>
|
||||
|
||||
<System.DescriptionGroup label="Bio" style={{ marginTop: 48 }} />
|
||||
<System.Input
|
||||
containerStyle={{ marginTop: 48 }}
|
||||
label="Name"
|
||||
description={`This is how your name will be publicly shown.`}
|
||||
name="name"
|
||||
value={this.state.name}
|
||||
placeholder="Your name"
|
||||
onChange={this._handleChange}
|
||||
/>
|
||||
|
||||
<System.DescriptionGroup label="Bio" style={{ marginTop: 24 }} />
|
||||
<System.Textarea
|
||||
style={{ marginTop: 24 }}
|
||||
label="Bio"
|
||||
@ -225,7 +239,7 @@ export default class SceneEditAccount extends React.Component {
|
||||
onClick={this._handleSaveBio}
|
||||
loading={this.state.changingBio}
|
||||
>
|
||||
Change bio
|
||||
Update information
|
||||
</System.ButtonPrimary>
|
||||
</div>
|
||||
|
||||
|
@ -88,11 +88,69 @@ const createKeysTable = db.schema.createTable("keys", function(table) {
|
||||
.defaultTo(db.raw("now()"));
|
||||
});
|
||||
|
||||
const createSubscriptionTable = db.schema.createTable("subscriptions", function(
|
||||
table
|
||||
) {
|
||||
table
|
||||
.uuid("id")
|
||||
.primary()
|
||||
.unique()
|
||||
.notNullable()
|
||||
.defaultTo(db.raw("uuid_generate_v4()"));
|
||||
table.string("owner_user_id").nullable();
|
||||
table.string("target_slate_id").nullable();
|
||||
table.string("target_user_id").nullable();
|
||||
table.jsonb("data").nullable();
|
||||
table
|
||||
.timestamp("created_at")
|
||||
.notNullable()
|
||||
.defaultTo(db.raw("now()"));
|
||||
});
|
||||
|
||||
const createTrustedTable = db.schema.createTable("trusted", function(table) {
|
||||
table
|
||||
.uuid("id")
|
||||
.primary()
|
||||
.unique()
|
||||
.notNullable()
|
||||
.defaultTo(db.raw("uuid_generate_v4()"));
|
||||
table.string("owner_user_id").nullable();
|
||||
table.string("target_user_id").nullable();
|
||||
table.jsonb("data").nullable();
|
||||
table
|
||||
.timestamp("created_at")
|
||||
.notNullable()
|
||||
.defaultTo(db.raw("now()"));
|
||||
});
|
||||
|
||||
const createActivityTable = db.schema.createTable("activity", function(table) {
|
||||
table
|
||||
.uuid("id")
|
||||
.primary()
|
||||
.unique()
|
||||
.notNullable()
|
||||
.defaultTo(db.raw("uuid_generate_v4()"));
|
||||
table.string("owner_slate_id").nullable();
|
||||
table.string("owner_user_id").nullable();
|
||||
table.jsonb("data").nullable();
|
||||
table
|
||||
.timestamp("created_at")
|
||||
.notNullable()
|
||||
.defaultTo(db.raw("now()"));
|
||||
});
|
||||
|
||||
// --------------------------
|
||||
// RUN
|
||||
// --------------------------
|
||||
|
||||
Promise.all([createUsersTable, createSlatesTable, createKeysTable]);
|
||||
Promise.all([
|
||||
createUsersTable,
|
||||
createSlatesTable,
|
||||
createKeysTable,
|
||||
createSubscriptionTable,
|
||||
createActivityTable,
|
||||
createTrustedTable,
|
||||
]);
|
||||
|
||||
console.log(`FINISHED: seed-database.js`);
|
||||
console.log(` CTRL +C to return to terminal.`);
|
||||
|
28
server.js
28
server.js
@ -106,8 +106,12 @@ app.prepare().then(async () => {
|
||||
viewer,
|
||||
creator: {
|
||||
username: creator.username,
|
||||
data: { photo: creator.data.photo, body: creator.data.body ? creator.data.body : "A user on Slate." },
|
||||
slates: JSON.parse(JSON.stringify(slates)),
|
||||
slates,
|
||||
data: {
|
||||
photo: creator.data.photo,
|
||||
name: creator.data.name ? creator.data.name : creator.username,
|
||||
body: creator.data.body ? creator.data.body : "A user on Slate.",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -144,8 +148,26 @@ app.prepare().then(async () => {
|
||||
return res.redirect("/403");
|
||||
}
|
||||
|
||||
const id = Utilities.getIdFromCookie(req);
|
||||
|
||||
let viewer = null;
|
||||
if (id) {
|
||||
viewer = await ViewerManager.getById({
|
||||
id,
|
||||
});
|
||||
}
|
||||
|
||||
return app.render(req, res, "/_/slate", {
|
||||
slate: JSON.parse(JSON.stringify({ ...slate, ownername: req.params.username })),
|
||||
viewer,
|
||||
creator: {
|
||||
username: creator.username,
|
||||
data: {
|
||||
photo: creator.data.photo,
|
||||
name: creator.data.name ? creator.data.name : creator.username,
|
||||
body: creator.data.body ? creator.data.body : "A user on Slate.",
|
||||
},
|
||||
},
|
||||
slate,
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user