Merge branch 'main' of github.com:filecoin-project/slate into @aminejv/email-fixes

This commit is contained in:
Aminejvm 2021-06-11 19:35:32 +01:00
commit 31c2a62bf5
69 changed files with 297 additions and 394 deletions

View File

@ -1,5 +1,6 @@
import * as Window from "~/common/window";
import * as Strings from "~/common/strings";
import * as Logging from "~/common/logging";
let pingTimeout = null;
let client = null;
@ -16,10 +17,10 @@ export const init = ({ resource = "", viewer, onUpdate, onNewActiveUser = () =>
return null;
}
console.log(`${resource}: init`);
Logging.log(`${resource}: init`);
if (client) {
console.log("ERROR: Already has websocket client");
Error.log("ERROR: Already has websocket client");
return client;
}
@ -39,7 +40,7 @@ export const init = ({ resource = "", viewer, onUpdate, onNewActiveUser = () =>
return null;
}
console.log(`${resource}: ping`);
Logging.log(`${resource}: ping`);
clearTimeout(pingTimeout);
pingTimeout = setTimeout(() => {
@ -63,7 +64,7 @@ export const init = ({ resource = "", viewer, onUpdate, onNewActiveUser = () =>
type = response.type;
data = response.data;
} catch (e) {
console.log(e);
Logging.error(e);
}
if (!data) {
@ -89,7 +90,7 @@ export const init = ({ resource = "", viewer, onUpdate, onNewActiveUser = () =>
} else {
setTimeout(() => {
client = null;
console.log(`Auto reconnecting dropped websocket`);
Logging.log("Auto reconnecting dropped websocket");
init({ resource, viewer, onUpdate });
}, 1000);
}
@ -97,7 +98,7 @@ export const init = ({ resource = "", viewer, onUpdate, onNewActiveUser = () =>
return null;
}
console.log(`${resource}: closed`);
Logging.log(`${resource}: closed`);
clearTimeout(pingTimeout);
});
@ -118,7 +119,7 @@ export const deleteClient = async () => {
}
if (!client) {
console.log("WEBSOCKET: NOTHING TO DELETE");
Logging.log("WEBSOCKET: NOTHING TO DELETE");
return null;
}
@ -128,7 +129,7 @@ export const deleteClient = async () => {
client = null;
await Window.delay(0);
console.log("WEBSOCKET: TERMINATED");
Logging.log("WEBSOCKET: TERMINATED");
return client;
};
@ -138,10 +139,10 @@ export const checkWebsocket = async () => {
return;
}
if (!savedResource || !savedViewer || !savedOnUpdate) {
console.log("no saved resources from previous, so not connecting a websocket");
Logging.log("No saved resources from previous, so not connecting a websocket");
return;
}
console.log("reconnecting dropped websocket");
Logging.log("Reconnecting dropped websocket");
init({ resource: savedResource, viewer: savedViewer, onUpdate: savedOnUpdate });
await Window.delay(2000);
return;

View File

@ -4,8 +4,6 @@ export const dispatchCustomEvent = ({ name, detail }) => {
};
export const hasError = (response) => {
console.log("insdie has error");
console.log(response);
if (!response) {
dispatchCustomEvent({
name: "create-alert",
@ -15,7 +13,6 @@ export const hasError = (response) => {
},
},
});
console.log(response);
return true;
} else if (response.error) {
dispatchCustomEvent({
@ -26,7 +23,6 @@ export const hasError = (response) => {
},
},
});
console.log(response);
return true;
}
return false;

View File

@ -5,6 +5,7 @@ import * as Credentials from "~/common/credentials";
import * as Strings from "~/common/strings";
import * as Validations from "~/common/validations";
import * as Events from "~/common/custom-events";
import * as Logging from "~/common/logging";
import { encode } from "blurhash";
@ -85,7 +86,7 @@ export const upload = async ({ file, context, bucketName, routes, excludeFromLib
XHR.open("post", path, true);
XHR.setRequestHeader("authorization", getCookie(Credentials.session.key));
XHR.onerror = (event) => {
console.log(event);
Logging.error(event);
XHR.abort();
};
@ -98,7 +99,7 @@ export const upload = async ({ file, context, bucketName, routes, excludeFromLib
}
if (event.lengthComputable) {
console.log("FILE UPLOAD PROGRESS", event);
Logging.log("FILE UPLOAD PROGRESS", event);
context.setState({
fileLoading: {
...context.state.fileLoading,
@ -117,7 +118,7 @@ export const upload = async ({ file, context, bucketName, routes, excludeFromLib
window.removeEventListener(`cancel-${file.lastModified}-${file.name}`, () => XHR.abort());
XHR.onloadend = (event) => {
console.log("FILE UPLOAD END", event);
Logging.log("FILE UPLOAD END", event);
try {
return resolve(JSON.parse(event.target.response));
} catch (e) {
@ -126,7 +127,6 @@ export const upload = async ({ file, context, bucketName, routes, excludeFromLib
});
}
};
console.log(formData);
XHR.send(formData);
});
@ -177,7 +177,7 @@ export const upload = async ({ file, context, bucketName, routes, excludeFromLib
let blurhash = await encodeImageToBlurhash(url);
item.data.blurhash = blurhash;
} catch (e) {
console.log(e);
Logging.error(e);
}
}

View File

@ -1,4 +1,5 @@
import * as React from "react";
import * as Logging from "~/common/logging";
export const useMounted = () => {
const isMounted = React.useRef(true);
@ -60,7 +61,7 @@ export const useForm = ({
setInternal((prev) => ({ ...prev, isValidating: true }));
errors = await validate(state.values, {});
} catch (e) {
console.log("validation", e);
Logging.error(e);
} finally {
setInternal((prev) => ({ ...prev, isValidating: false }));
setState((prev) => ({
@ -102,7 +103,7 @@ export const useForm = ({
errors = await validate(state.values, { ...state.errors });
if (_hasError(errors)) return;
} catch (e) {
console.log("validation", e);
Logging.error(e);
} finally {
setInternal((prev) => ({ ...prev, isValidating: false }));
setState((prev) => ({ ...prev, errors }));
@ -115,7 +116,7 @@ export const useForm = ({
try {
await onSubmit(state.values);
} catch (e) {
console.log("submitting", e);
Logging.error(e);
} finally {
setInternal((prev) => ({ ...prev, isSubmitting: false }));
}
@ -125,7 +126,7 @@ export const useForm = ({
e.preventDefault();
submitAsync()
.then()
.catch((e) => console.log(e));
.catch((e) => Logging.error(e));
};
// Note(Amine): this prop getter will overide the form onSubmit handler

View File

@ -1,8 +1,5 @@
const getTimestamp = () => {
return new Date()
.toISOString()
.replace(/T/, " ")
.replace(/\..+/, "");
return new Date().toISOString().replace(/T/, " ").replace(/\..+/, "");
};
const getTime = () => {
@ -11,10 +8,10 @@ const getTime = () => {
const SLATE = "SLATE ";
export const error = (message) => {
console.log(`\x1b[1m[ \x1b[31m${SLATE}\x1b[0m\x1b[1m ]\x1b[0m ${getTime()} ${message}`);
export const error = (...message) => {
console.log(`\x1b[1m[ \x1b[31m${SLATE}\x1b[0m\x1b[1m ]\x1b[0m ${getTime()} `, ...message);
};
export const log = (message) => {
console.log(`\x1b[1m[ \x1b[32m${SLATE}\x1b[0m\x1b[1m ]\x1b[0m ${getTime()} ${message}`);
export const log = (...message) => {
console.log(`\x1b[1m[ \x1b[32m${SLATE}\x1b[0m\x1b[1m ]\x1b[0m ${getTime()} `, ...message);
};

View File

@ -295,7 +295,6 @@ export const removeFromSlate = async ({ slate, ids }) => {
//NOTE(martina): save copy includes add to slate now. If it's already in the user's files but not in that slate, it'll skip the adding to files and just add to slate
export const saveCopy = async ({ files, slate }) => {
console.log("user behaviors save copy");
let response = await Actions.saveCopy({ files, slate });
if (Events.hasError(response)) {
return false;

View File

@ -12,6 +12,7 @@ import * as Store from "~/common/store";
import * as Websockets from "~/common/browser-websockets";
import * as UserBehaviors from "~/common/user-behaviors";
import * as Events from "~/common/custom-events";
import * as Logging from "~/common/logging";
// NOTE(jim):
// Scenes each have an ID and can be navigated to with _handleAction
@ -207,7 +208,6 @@ export default class ApplicationPage extends React.Component {
if (callback) {
callback();
}
console.log(this.state.viewer);
}
);
return;
@ -218,7 +218,6 @@ export default class ApplicationPage extends React.Component {
viewer: { ...this.state.viewer, ...viewer },
},
() => {
console.log(this.state.viewer);
if (callback) {
callback();
}
@ -244,7 +243,7 @@ export default class ApplicationPage extends React.Component {
}
if (this.props.resources && !Strings.isEmpty(this.props.resources.pubsub)) {
if (!this.state.viewer) {
console.log("WEBSOCKET: NOT AUTHENTICATED");
Logging.error("WEBSOCKET: NOT AUTHENTICATED");
return;
}
wsclient = Websockets.init({
@ -276,7 +275,7 @@ export default class ApplicationPage extends React.Component {
// only change if necessary.
if (this.state.isMobile !== isMobile) {
console.log("changing to mobile?", isMobile);
Logging.log("changing to mobile?", isMobile);
this.setState({ isMobile });
}
};
@ -348,7 +347,7 @@ export default class ApplicationPage extends React.Component {
routes: this.props.resources,
});
} catch (e) {
console.log(e);
Logging.error(e);
}
if (!response || response.error) {
@ -484,7 +483,7 @@ export default class ApplicationPage extends React.Component {
return viewer;
}
this.setState({ viewer }, () => console.log(this.state.viewer));
this.setState({ viewer });
await this._handleSetupWebsocket();
let unseenAnnouncements = [];
@ -578,7 +577,7 @@ export default class ApplicationPage extends React.Component {
return window.open(options.value);
}
console.log("Error: Failed to _handleAction because TYPE did not match any known actions");
Logging.error("Error: Failed to _handleAction because TYPE did not match any known actions");
};
_handleNavigateTo = async ({ href, redirect = false, popstate = false }) => {

View File

@ -684,7 +684,7 @@ class CarouselSidebar extends React.Component {
{
this.props.carouselType === "ACTIVITY"
? actions.push(
<div style={{ borderBottom: "1px solid #3c3c3c" }}>
<div key="go-to-slate" style={{ borderBottom: "1px solid #3c3c3c" }}>
<Link href={`/$/slate/${file.slateId}`} onAction={this.props.onAction}>
<div
key="go-to-slate"

View File

@ -562,7 +562,6 @@ export default class DataView extends React.Component {
const url = Strings.getURLfromCID(object.cid);
const title = object.filename || object.data.name;
const type = object.data.type;
console.log(e.dataTransfer, e.dataTransfer.setData);
e.dataTransfer.setData("DownloadURL", `${type}:${title}:${url}`);
};

View File

@ -1,5 +1,6 @@
import * as React from "react";
import * as Strings from "~/common/strings";
import * as Logging from "~/common/logging";
export class Link extends React.Component {
state = {
@ -12,7 +13,7 @@ export class Link extends React.Component {
static defaultProps = {
onUpdate: () => {
console.log(
Logging.error(
`ERROR: onUpdate is missing from a Link object called with href ${this.props.href}`
);
},

View File

@ -5,6 +5,7 @@ import * as Actions from "~/common/actions";
import * as Strings from "~/common/strings";
import * as Window from "~/common/window";
import * as Validations from "~/common/validations";
import * as Logging from "~/common/logging";
import MiniSearch from "minisearch";
import SlateMediaObjectPreview from "~/components/core/SlateMediaObjectPreview";
@ -448,8 +449,7 @@ const getHref = (result) => {
} else if (result.type === "DATA_FILE") {
return `/_/data?cid=${result.data.file.cid}`;
} else {
console.log("GET HREF FAILED B/C RESULT WAS:");
console.log(result);
Logging.error("Get href failed because result was:", result);
}
};
@ -637,7 +637,6 @@ export class SearchModal extends React.Component {
} else if (e.keyCode === 13) {
if (results.length > this.state.selectedIndex && this.state.selectedIndex >= 0) {
let href = results[this.state.selectedIndex].href;
console.log("key down navigate");
this.props.onAction({ type: "NAVIGATE", href });
}
e.preventDefault();
@ -780,7 +779,6 @@ export class SearchModal extends React.Component {
results = results.map((res) => {
return { ...res, href: getHref(res) };
});
console.log(results);
this.setState({ results, selectedIndex: 0 });
if (this._optionRoot) {
this._optionRoot.scrollTop = 0;
@ -949,11 +947,7 @@ export class SearchModal extends React.Component {
_handleSelectIndex = (i) => {
if (this.state.selectedIndex === i || this.props.isMobile) {
console.log("handle hide");
this._handleHide();
} else {
console.log("set state");
// this.setState({ selectedIndex: i });
}
};
@ -1182,13 +1176,13 @@ export class SearchModal extends React.Component {
>
{results.map((each, i) => (
<Link
key={each.id}
disabled={this.props.isMobile ? false : selectedIndex !== i}
href={each.href}
onAction={this.props.onAction}
onClick={() => this._handleSelectIndex(i)}
>
<div
key={each.id}
css={STYLES_DROPDOWN_ITEM}
style={{
background:

View File

@ -1058,7 +1058,6 @@ export class SlateLayout extends React.Component {
const url = Strings.getURLfromCID(object.cid);
const title = object.filename || object.data.name;
const type = object.data.type;
console.log(e.dataTransfer, e.dataTransfer.setData);
e.dataTransfer.setData("DownloadURL", `${type}:${title}:${url}`);
};

View File

@ -197,9 +197,7 @@ export default class SlateMediaObjectPreview extends React.Component {
style={{ color: Constants.system.textGray }}
/>
);
if (!file.filename) {
console.log(file);
}
if (Validations.isFontFile(file.filename)) {
return (
<article

View File

@ -45,8 +45,6 @@ export default class SidebarFileStorageDeal extends React.Component {
return null;
}
console.log("SETTINGS: AUTO DEAL");
await this._handleSubmit();
}
@ -63,7 +61,6 @@ export default class SidebarFileStorageDeal extends React.Component {
const response = await fetch("/api/data/storage-deal", options);
const json = await response.json();
console.log(json);
return json;
};

View File

@ -73,7 +73,6 @@ export default class CreateChart extends React.Component {
loopData = (g) => {
let coordinates = [];
let i = {};
console.log(g);
g.map((o, index) => {
coordinates.push(o.x);
coordinates.push(o.y);

View File

@ -123,10 +123,7 @@ export class ListEditor extends React.Component {
target: { name: this.props.name, value: this.state.options },
});
}
this.setState({ expand: !this.state.expand }),
() => {
console.log(this.state.expand);
};
this.setState({ expand: !this.state.expand });
};
_handleDelete = (i) => {

View File

@ -7,6 +7,7 @@ import * as React from "react";
import * as Constants from "~/common/constants";
import * as SubSystem from "~/components/system/components/fragments/TableComponents";
import * as SVG from "~/common/svg";
import * as Logging from "~/common/logging";
import { css } from "@emotion/react";
import { P } from "~/components/system/components/Typography";
@ -83,7 +84,7 @@ const STYLES_TABLE_TOP_ROW = css`
export class Table extends React.Component {
static defaultProps = {
onAction: () => console.log("No action function set"),
onAction: () => Logging.error("No action function set"),
onChange: () => {},
};

View File

@ -453,11 +453,8 @@ export const Tag = ({
if ((tags || []).find((tag) => tag.toLowerCase() === value.toLowerCase().trim())) {
return;
}
console.log("inside handle add");
if (onChange) {
console.log("on change exists");
onChange({ target: { name: "tags", value: [...tags, value.trim()] } });
console.log("after onchange");
setValue("");
}
};
@ -489,7 +486,7 @@ export const Tag = ({
};
const _handleFocus = () => setOpen(true);
// console.log({ suggestions });
return (
<div css={STYLES_TAG_CONTAINER} style={{ ...style }}>
<div css={STYLES_INPUT_CONTAINER}>

View File

@ -104,15 +104,6 @@ export class GlobalTooltip extends React.Component {
};
_handleAdd = (e) => {
// if (
// this.props.allowedTypes &&
// !this.props.allowedTypes.includes(e.detail.type)
// ) {
// return;
// }
// console.log("got here");
// if (!e.detail.bubbleRect.width && !e.detail.bubbleRect.height) return;
// console.log("had width and height");
let tooltips = this.state.tooltips;
tooltips[e.detail.id] = {
id: e.detail.id,
@ -139,14 +130,11 @@ export class GlobalTooltip extends React.Component {
};
_handleShow = async (e) => {
console.log(this.state.tooltips);
console.log(this.state.tooltips[e.detail.id]);
if (this.state.tooltips[e.detail.id]) {
let tooltips = this.state.tooltips;
if (!tooltips[e.detail.id].style) {
let anchor = tooltips[e.detail.id].root;
let rect = anchor.getBoundingClientRect();
console.log(rect);
let style = this.getOrientation(
rect,
tooltips[e.detail.id].bubbleRect,
@ -201,7 +189,6 @@ export class TooltipWrapper extends React.Component {
componentDidMount = () => {
let bubbleRect = this._bubble.getBoundingClientRect();
console.log(this._bubble);
Events.dispatchCustomEvent({
name: "add-tooltip",

View File

@ -14,14 +14,12 @@ const STYLES_NESTED_TABLE = css`
const NestedTable = (data) => {
let values = [];
console.log(Object.entries(data));
for (let entries of Object.entries(data)) {
if (entries[0] !== "rootCid") {
values.push(<div key={entries[0]}>{entries[0]}</div>);
values.push(<div key={`${entries[0]}value`}>{entries[1]}</div>);
}
}
console.log(values);
return <div css={STYLES_NESTED_TABLE}>{values}</div>;
};

View File

@ -10,8 +10,7 @@ export const removeDuplicateUserFiles = async ({ files, user }) => {
const duplicateCids = duplicateFiles.map((file) => file.cid);
const filteredFiles = files.filter((file) => !duplicateCids.includes(file.cid));
console.log(duplicateFiles);
console.log(filteredFiles);
return { duplicateFiles, filteredFiles };
};

View File

@ -6,12 +6,6 @@ export default async ({ ids, ownerId }) => {
return await runQuery({
label: "DELETE_FILES_BY_IDS",
queryFn: async (DB) => {
console.log("inside delete files by ids");
// const repostedSlateFiles = await DB.from("slate_files")
// .join("slates", "slates.id", "=", "slate_files.slateId")
// .whereNot("slates.ownerId", "=", ownerId)
// .whereIn("slate_files.fileId", ids)
// .update({ "slate_files.fileId": null });
const repostedSlateFiles = await DB.from("slate_files")
.whereIn("id", function () {
this.select("slate_files.id")

View File

@ -1,3 +1,5 @@
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
export default async ({
@ -123,7 +125,7 @@ export default async ({
return JSON.parse(JSON.stringify(query));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_ACTIVITY_FOR_USER_ID",
});

View File

@ -1,3 +1,5 @@
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
export default async ({ userId }) => {
@ -13,7 +15,7 @@ export default async ({ userId }) => {
return JSON.parse(JSON.stringify(query));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_API_KEYS_BY_USER_ID",
});

View File

@ -1,3 +1,4 @@
import * as Logging from "~/common/logging";
import * as Serializers from "~/node_common/serializers";
import { runQuery } from "~/node_common/data/utilities";
@ -24,7 +25,7 @@ export default async ({ sanitize = false, publicOnly = false } = {}) => {
return JSON.parse(JSON.stringify(files));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_EVERY_FILE",
});

View File

@ -1,3 +1,4 @@
import * as Logging from "~/common/logging";
import * as Serializers from "~/node_common/serializers";
import * as Constants from "~/node_common/constants";
@ -53,7 +54,7 @@ export default async ({ sanitize = false, includeFiles = false, publicOnly = fal
return JSON.parse(JSON.stringify(slates));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_EVERY_SLATE",
});

View File

@ -1,3 +1,4 @@
import * as Logging from "~/common/logging";
import * as Serializers from "~/node_common/serializers";
import * as Constants from "~/node_common/constants";
@ -36,7 +37,7 @@ export default async ({ sanitize = false, includeFiles = false } = {}) => {
return JSON.parse(JSON.stringify(users));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_EVERY_USER",
});

View File

@ -1,3 +1,5 @@
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
export default async ({ earliestTimestamp, latestTimestamp }) => {
@ -84,7 +86,7 @@ export default async ({ earliestTimestamp, latestTimestamp }) => {
return JSON.parse(JSON.stringify(query));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_EXPLORE",
});

View File

@ -1,8 +1,9 @@
import { runQuery } from "~/node_common/data/utilities";
import * as Constants from "~/node_common/constants";
import * as Logging from "~/common/logging";
import * as Serializers from "~/node_common/serializers";
import { runQuery } from "~/node_common/data/utilities";
export default async ({ userId }) => {
return await runQuery({
label: "GET_FOLLOWERS_BY_USER_ID",
@ -24,7 +25,7 @@ export default async ({ userId }) => {
return JSON.parse(JSON.stringify(serialized));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_FOLLOWERS_BY_USER_ID",
});

View File

@ -1,8 +1,9 @@
import { runQuery } from "~/node_common/data/utilities";
import * as Constants from "~/node_common/constants";
import * as Logging from "~/common/logging";
import * as Serializers from "~/node_common/serializers";
import { runQuery } from "~/node_common/data/utilities";
export default async ({ ownerId }) => {
return await runQuery({
label: "GET_FOLLOWING_BY_USER_ID",
@ -25,7 +26,7 @@ export default async ({ ownerId }) => {
return JSON.parse(JSON.stringify(serialized));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_FOLLOWING_BY_USER_ID",
});

View File

@ -1,5 +1,6 @@
import * as Constants from "~/node_common/constants";
import * as Serializers from "~/node_common/serializers";
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
@ -25,7 +26,7 @@ export default async ({ ownerId }) => {
return JSON.parse(JSON.stringify(serialized));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_LIKES_BY_USER_ID",
});

View File

@ -1,5 +1,6 @@
import * as Serializers from "~/node_common/serializers";
import * as Constants from "~/node_common/constants";
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
@ -72,7 +73,7 @@ export default async ({ ownerId, sanitize = false, includeFiles = false, publicO
return JSON.parse(JSON.stringify(query));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_SLATES_BY_USER_ID",
});

View File

@ -1,5 +1,6 @@
import * as Serializers from "~/node_common/serializers";
import * as Constants from "~/node_common/constants";
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
@ -25,7 +26,7 @@ export default async ({ slateId }) => {
return JSON.parse(JSON.stringify(serialized));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_SUBSCRIBERS_BY_SLATE_ID",
});

View File

@ -1,5 +1,6 @@
import * as Serializers from "~/node_common/serializers";
import * as Constants from "~/node_common/constants";
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
@ -39,7 +40,7 @@ export default async ({ ownerId }) => {
return JSON.parse(JSON.stringify(serialized));
},
errorFn: async (e) => {
console.log({
Logging.error({
error: true,
decorator: "GET_SUBSCRIPTIONS_BY_USER_ID",
});

View File

@ -1,9 +1,9 @@
import * as Logging from "~/common/logging";
import { runQuery } from "~/node_common/data/utilities";
//NOTE(martina): this method is specifically for making *multiple* files from one owner *public*. It will filter out the already public files
export default async ({ ids, ownerId }) => {
console.log(ids);
console.log(ownerId);
return await runQuery({
label: "UPDATE_FILES_PUBLIC",
queryFn: async (DB) => {

View File

@ -1,4 +1,4 @@
import * as NodeLogging from "~/node_common/node-logging";
import * as Logging from "~/common/logging";
import DB from "~/node_common/database";
@ -7,10 +7,10 @@ export const runQuery = async ({ queryFn, errorFn, label }) => {
try {
response = await queryFn(DB);
} catch (e) {
NodeLogging.error(`DB:${label}: ${e.message}`);
Logging.error(`DB:${label}: ${e.message}`);
response = errorFn(e);
}
NodeLogging.log(`DB:${label}`);
Logging.log(`DB:${label}`);
return response;
};

View File

@ -1,3 +1,4 @@
import * as Logging from "~/common/logging";
import * as Environment from "~/node_common/environment";
import sgMail from "@sendgrid/mail";
@ -45,7 +46,7 @@ export const sendTemplate = async ({ to, from, templateId, templateData }) => {
try {
await sgMail.send(msg);
} catch (error) {
console.log("SOMETHING", error);
Logging.error(error);
return { decorator: "SEND_TEMPLATE_EMAIL_FAILURE", error: true };
}
};

View File

@ -5,7 +5,7 @@ import * as Constants from "~/node_common/constants";
import * as Serializers from "~/node_common/serializers";
import * as Strings from "~/common/strings";
import * as Websocket from "~/node_common/nodejs-websocket";
import * as NodeLogging from "~/node_common/node-logging";
import * as Logging from "~/common/logging";
import * as Window from "~/common/window";
import WebSocket from "ws";
@ -39,10 +39,9 @@ const websocketSend = async (type, data) => {
};
export const updateUser = async (user, action) => {
console.log("UPDATE SEARCH for user");
if (!user || !action) return;
NodeLogging.log(`Search is updating user ...`);
Logging.log(`Search is updating user ...`);
let data;
if (Array.isArray(user)) {
@ -60,10 +59,9 @@ export const updateUser = async (user, action) => {
};
export const updateSlate = async (slate, action) => {
console.log("UPDATE SEARCH for slate");
if (!slate || !action) return;
NodeLogging.log(`Search is updating slate ...`);
Logging.log(`Search is updating slate ...`);
let data;
if (Array.isArray(slate)) {
@ -81,10 +79,9 @@ export const updateSlate = async (slate, action) => {
};
export const updateFile = async (file, action) => {
console.log("UPDATE SEARCH for file");
if (!file || !action) return;
NodeLogging.log(`Search is updating file ...`);
Logging.log(`Search is updating file ...`);
let data;
if (Array.isArray(file)) {

View File

@ -8,6 +8,7 @@ import * as Strings from "~/common/strings";
import * as Window from "~/common/window";
import * as Websocket from "~/node_common/nodejs-websocket";
import * as Filecoin from "~/common/filecoin";
import * as Logging from "~/common/logging";
import WebSocket from "ws";
@ -133,13 +134,6 @@ export const getById = async ({ id }) => {
includeFiles: true,
});
// try {
// JSON.stringify(user);
// } catch (e) {
// console.log(user);
// console.log("errored on json.stringify user (1st time)");
// }
if (!user) {
return null;
}
@ -231,13 +225,6 @@ export const getById = async ({ id }) => {
followers,
};
// try {
// JSON.stringify(viewer);
// } catch (e) {
// console.log(viewer);
// console.log("errored on json.stringify viewer (2nd time)");
// }
return viewer;
};
@ -297,7 +284,7 @@ export const getDealHistory = async ({ id }) => {
});
}
} catch (e) {
console.log(e);
Logging.error(e);
Social.sendTextileSlackMessage({
file: "/node_common/managers/viewer.js",
user,

View File

@ -3,6 +3,7 @@ import * as Credentials from "~/common/credentials";
import * as Strings from "~/common/strings";
import * as Data from "~/node_common/data";
import * as Powergate from "~/node_common/powergate";
import * as Logging from "~/common/logging";
import JWT from "jsonwebtoken";
@ -51,7 +52,7 @@ export const RequireCookieAuthentication = async (req, res, next) => {
return res.status(403).json({ decorator: "SERVER_AUTH_USER_NOT_FOUND", error: true });
}
} catch (err) {
console.log(err);
Logging.error(err);
return res.status(403).json({ decorator: "SERVER_AUTH_USER_ERROR", error: true });
}

View File

@ -1,5 +1,6 @@
import * as Social from "~/node_common/social";
import * as Arrays from "~/common/arrays";
import * as Logging from "~/common/logging";
//things taht could be combined into this:
//update search (searchmanager)
@ -21,29 +22,10 @@ export const error = (location, e) => {
const message = `@martina there was an error at ${location}: ${e}`;
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};
// export const upload = ({ user, files: targetFiles }) => {
// const files = Arrays.filterPublic(targetFiles);
// if (!files.length) {
// return;
// }
// try {
// const userURL = getUserURL(user);
// const objectURL = `<https://slate.host/${user.username}?cid=${files[0].cid}|${files[0].filename}>`;
// const extra =
// files.length > 1
// ? ` and ${files.length - 1} other file${files.length - 1 > 1 ? "s " : " "}`
// : "";
// const message = `*${userURL}* uploaded ${objectURL}${extra}`;
// Social.sendSlackMessage(message);
// } catch (e) {
// console.log(e);
// }
// };
export const upload = ({ user, slate, files: targetFiles }) => {
if (slate && !slate.isPublic) return;
const files = Arrays.filterPublic(targetFiles);
@ -67,7 +49,7 @@ export const upload = ({ user, slate, files: targetFiles }) => {
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};
@ -86,31 +68,10 @@ export const download = ({ user, files: targetFiles }) => {
const message = `*${userURL}* downloaded ${objectURL}${extra}`;
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};
// export const addToSlate = ({ slate, user, files: targetFiles }) => {
// if (!slate.isPublic) return;
// const files = Arrays.filterPublic(targetFiles);
// if (!files.length) {
// return;
// }
// try {
// const userURL = getUserURL(user);
// const objectURL = `<https://slate.host/${user.username}/${slate.slatename}?cid=${files[0].filename}|${files[0].cid}>`;
// const extra =
// files.length > 1
// ? ` and ${files.length - 1} other file${files.length - 1 > 1 ? "s " : " "}`
// : "";
// const message = `*${userURL}* saved ${objectURL}${extra} to https://slate.host/${user.username}/${slate.slatename}`;
// Social.sendSlackMessage(message);
// } catch (e) {
// console.log(e);
// }
// };
export const saveCopy = ({ slate, user, files: targetFiles }) => {
if (slate && !slate.isPublic) return;
const files = Arrays.filterPublic(targetFiles);
@ -134,30 +95,10 @@ export const saveCopy = ({ slate, user, files: targetFiles }) => {
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};
// export const saveCopy = ({ user, files: targetFiles }) => {
// const files = Arrays.filterPublic(targetFiles);
// if (!files.length) {
// return;
// }
// try {
// const userURL = getUserURL(user);
// const objectURL = `<https://slate.host/${user.username}?cid=${files[0].cid}|${files[0].filename}>`;
// const extra =
// files.length > 1
// ? ` and ${files.length - 1} other file${files.length - 1 > 1 ? "s " : " "}`
// : "";
// const message = `*${userURL}* saved ${objectURL}${extra}`;
// Social.sendSlackMessage(message);
// } catch (e) {
// console.log(e);
// }
// };
export const createSlate = ({ user, slate }) => {
if (!slate.isPublic) return;
try {
@ -166,7 +107,7 @@ export const createSlate = ({ user, slate }) => {
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};
@ -177,7 +118,7 @@ export const createUser = ({ user }) => {
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};
@ -190,7 +131,7 @@ export const subscribeUser = ({ user, targetUser }) => {
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};
@ -206,6 +147,6 @@ export const subscribeSlate = ({ user, targetSlate }) => {
Social.sendSlackMessage(message);
} catch (e) {
console.log(e);
Logging.error(e);
}
};

View File

@ -1,7 +1,6 @@
import * as Environment from "~/node_common/environment";
import * as ScriptLogging from "~/node_common/script-logging";
import * as Strings from "~/common/strings";
import * as NodeLogging from "~/node_common/node-logging";
import * as Logging from "~/common/logging";
import WebSocket from "ws";
@ -24,7 +23,7 @@ export const create = () => {
clearTimeout(this.pingTimeout);
this.pingTimeout = setTimeout(() => {
NodeLogging.log(`Did not receive ping in time. Disconnecting websocket`);
Logging.log(`Did not receive ping in time. Disconnecting websocket`);
this.terminate();
}, 30000 + 1000);
});
@ -36,13 +35,13 @@ export const create = () => {
ws.on("close", () => {
global.websocket = null;
setTimeout(() => {
NodeLogging.log(`Auto reconnecting websocket`);
Logging.log(`Auto reconnecting websocket`);
create();
}, 1000);
NodeLogging.log(`Websocket disconnected`);
Logging.log(`Websocket disconnected`);
});
NodeLogging.log(`Websocket server started`);
Logging.log(`Websocket server started`);
global.websocket = ws;
return global.websocket;

View File

@ -1,5 +1,6 @@
import * as Environment from "~/node_common/environment";
import * as Strings from "~/common/strings";
import * as Logging from "~/common/logging";
import { IncomingWebhook } from "@slack/webhook";
@ -12,8 +13,6 @@ const textileURL = `https://hooks.slack.com/services/${Environment.TEXTILE_SLACK
const textileWebhook = new IncomingWebhook(textileURL);
export const sendSlackMessage = (message) => {
console.log("Inside send slack message");
console.log({ slackMessage: message });
if (Strings.isEmpty(Environment.SOCIAL_SLACK_WEBHOOK_KEY)) {
return;
}
@ -21,7 +20,7 @@ export const sendSlackMessage = (message) => {
try {
webhook.send({ text: message });
} catch (e) {
console.log({ decorator: "SLACK_MESSAGE_FAILURE", message });
Logging.error("SLACK_MESSAGE_FAILURE", message);
}
};
@ -47,6 +46,6 @@ export const sendTextileSlackMessage = ({
text: `*Source code —* ${slackFileURL} \n*Source client —* ${source} \n*Callsite —* \`${functionName}\`\n*User —* ${userURL}\n\n> ${message}\n\n*Textile error code —* ${code}`,
});
} catch (e) {
console.log({ decorator: "SLACK_MESSAGE_FAILURE", message });
Logging.error("SLACK_MESSAGE_FAILURE", message);
}
};

View File

@ -3,7 +3,7 @@ import * as Strings from "~/common/strings";
import * as Constants from "~/node_common/constants";
import * as Data from "~/node_common/data";
import * as Social from "~/node_common/social";
import * as NodeLogging from "~/node_common/node-logging";
import * as Logging from "~/common/logging";
import crypto from "crypto";
import JWT from "jsonwebtoken";
@ -70,7 +70,7 @@ export const getIdFromCookie = (req) => {
const decoded = JWT.verify(token, Environment.JWT_SECRET);
id = decoded.id;
} catch (e) {
console.log(e.message);
Logging.error(e.message);
}
}
@ -116,7 +116,7 @@ export const getFilecoinAPIFromUserToken = async ({ user }) => {
const filecoin = await Filecoin.withKeyInfo(TEXTILE_KEY_INFO);
await filecoin.getToken(identity);
NodeLogging.log(`filecoin init`);
Logging.log(`filecoin init`);
return {
filecoin,
@ -164,14 +164,14 @@ export const getBucketAPIFromUserToken = async ({ user, bucketName, encrypted =
await buckets.getToken(identity);
let root = null;
NodeLogging.log(`buckets.getOrCreate() init ${name}`);
Logging.log(`buckets.getOrCreate() init ${name}`);
try {
console.log("before buckets get or create");
Logging.log("before buckets get or create");
const created = await buckets.getOrCreate(name, { encrypted });
console.log("after buckets get or create");
Logging.log("after buckets get or create");
root = created.root;
} catch (e) {
NodeLogging.log(`buckets.getOrCreate() warning: ${e.message}`);
Logging.log(`buckets.getOrCreate() warning: ${e.message}`);
Social.sendTextileSlackMessage({
file: "/node_common/utilities.js",
user,
@ -182,12 +182,11 @@ export const getBucketAPIFromUserToken = async ({ user, bucketName, encrypted =
}
if (!root) {
NodeLogging.error(`buckets.getOrCreate() failed for ${name}`);
console.log(user);
Logging.error(`buckets.getOrCreate() failed for ${name}`);
return { buckets: null, bucketKey: null, bucketRoot: null };
}
NodeLogging.log(`buckets.getOrCreate() success for ${name}`);
Logging.log(`buckets.getOrCreate() success for ${name}`);
return {
buckets,
bucketKey: root.key,

View File

@ -23,7 +23,6 @@ export default class SlateReactSystemPage extends React.Component {
});
const json = await response.json();
console.log(json);
}
_handleUpload = async (e) => {
@ -43,12 +42,9 @@ export default class SlateReactSystemPage extends React.Component {
});
const json = await response.json();
console.log(json);
};
render() {
console.log(System.Constants);
return (
<div>
<System.GlobalTooltip />

View File

@ -1,6 +1,7 @@
import * as Utilities from "~/node_common/utilities";
import * as Data from "~/node_common/data";
import * as Powergate from "~/node_common/powergate";
import * as Logging from "~/common/logging";
export default async (req, res) => {
const id = Utilities.getIdFromCookie(req);
@ -23,7 +24,7 @@ export default async (req, res) => {
try {
await PG.ffs.sendFil(req.body.data.source, req.body.data.target, req.body.data.amount);
} catch (e) {
console.log(e);
Logging.error(e);
return res.status(500).send({ decorator: "SERVER_SEND_FILECOIN_ACTION_FAILURE", error: true });
}

View File

@ -2,6 +2,7 @@ import * as Data from "~/node_common/data";
import * as Utilities from "~/node_common/utilities";
import * as Social from "~/node_common/social";
import * as Strings from "~/common/strings";
import * as Logging from "~/common/logging";
import { v4 as uuid } from "uuid";
import { MAX_BUCKET_COUNT, MIN_ARCHIVE_SIZE_BYTES } from "~/node_common/constants";
@ -74,7 +75,7 @@ export default async (req, res) => {
});
}
console.log(`[ deal ] will make a deal for ${items.items.length} items`);
Logging.log(`[ deal ] will make a deal for ${items.items.length} items`);
if (items.items.length < 2) {
return res.status(500).send({
decorator: "SERVER_ARCHIVE_NO_FILES",
@ -82,7 +83,7 @@ export default async (req, res) => {
});
}
console.log(`[ deal ] deal size: ${Strings.bytesToSize(bucketSizeBytes)}`);
Logging.log(`[ deal ] deal size: ${Strings.bytesToSize(bucketSizeBytes)}`);
if (bucketSizeBytes < MIN_ARCHIVE_SIZE_BYTES) {
return res.status(500).send({
decorator: "SERVER_ARCHIVE_BUCKET_TOO_SMALL",
@ -113,7 +114,7 @@ export default async (req, res) => {
});
}
console.log(
Logging.log(
`[ encrypted ] user has ${userBuckets.length} out of ${MAX_BUCKET_COUNT} buckets used.`
);
if (userBuckets.length >= MAX_BUCKET_COUNT) {
@ -140,7 +141,7 @@ export default async (req, res) => {
? `encrypted-deal-${uuid()}`
: `encrypted-data-${uuid()}`;
console.log(`[ encrypted ] making an ${encryptedBucketName} for this storage deal.`);
Logging.log(`[ encrypted ] making an ${encryptedBucketName} for this storage deal.`);
try {
const newBucket = await buckets.create(encryptedBucketName, true, items.cid);
@ -160,8 +161,8 @@ export default async (req, res) => {
});
}
console.log(`[ encrypted ] ${encryptedBucketName}`);
console.log(`[ encrypted ] ${key}`);
Logging.log(`[ encrypted ] ${encryptedBucketName}`);
Logging.log(`[ encrypted ] ${key}`);
} else {
const newDealBucketName = `open-deal-${uuid()}`;
@ -183,8 +184,8 @@ export default async (req, res) => {
});
}
console.log(`[ normal ] ${newDealBucketName}`);
console.log(`[ normal ] ${key}`);
Logging.log(`[ normal ] ${newDealBucketName}`);
Logging.log(`[ normal ] ${key}`);
}
// NOTE(jim): Finally make the deal
@ -192,9 +193,8 @@ export default async (req, res) => {
let response = {};
let error = {};
try {
console.log(`[ deal-maker ] deal being made for ${key}`);
Logging.log(`[ deal-maker ] deal being made for ${key}`);
if (req.body.data && req.body.data.settings) {
console.log(req.body.data.settings);
response = await buckets.archive(key, req.body.data.settings);
} else {
response = await buckets.archive(key);
@ -202,7 +202,7 @@ export default async (req, res) => {
} catch (e) {
error.message = e.message;
error.code = e.code;
console.log(e.message);
Logging.log(e.message);
Social.sendTextileSlackMessage({
file: "/pages/api/data/archive.js",

View File

@ -55,8 +55,6 @@ export default async (req, res) => {
files,
user,
});
console.log(filteredFiles);
console.log(duplicateFiles);
// if (!newFiles.length) {
// return res.status(400).send({ decorator: "SERVER_CREATE_FILE_DUPLICATE", error: true });
@ -74,7 +72,6 @@ export default async (req, res) => {
return res.status(500).send({ decorator: createdFiles.decorator, error: createdFiles.error });
}
}
console.log(createdFiles);
let added = createdFiles?.length || 0;

View File

@ -1,8 +1,10 @@
import * as Logging from "~/common/logging";
import * as Environment from "~/node_common/environment";
import * as Utilities from "~/node_common/utilities";
import * as Data from "~/node_common/data";
import * as Strings from "~/common/strings";
import * as Validations from "~/common/validations";
import { encryptPasswordClient } from "~/common/utilities";
import JWT from "jsonwebtoken";
@ -27,7 +29,7 @@ export default async (req, res) => {
try {
user = await Data.getUserByEmail({ email: username });
} catch (e) {
console.log(e);
Logging.error(e);
}
} else {
try {
@ -35,7 +37,7 @@ export default async (req, res) => {
username: req.body.data.username.toLowerCase(),
});
} catch (e) {
console.log(e);
Logging.error(e);
}
}

View File

@ -2,6 +2,7 @@ import * as Environment from "~/node_common/environment";
import * as Utilities from "~/node_common/utilities";
import * as Data from "~/node_common/data";
import * as Strings from "~/common/strings";
import * as Logging from "~/common/logging";
import JWT from "jsonwebtoken";
@ -51,7 +52,7 @@ export default async (req, res) => {
});
twitterUser = JSON.parse(response.data);
} catch (err) {
console.log(err);
Logging.error(err);
return res.status(500).send({ decorator: "SERVER_TWITTER_OAUTH_FAILED", error: true });
}
if (!twitterUser) {

View File

@ -1,6 +1,7 @@
import * as Environment from "~/node_common/environment";
import * as Data from "~/node_common/data";
import * as Strings from "~/common/strings";
import * as Logging from "~/common/logging";
import { createOAuthProvider } from "~/node_common/managers/twitter";
@ -23,7 +24,7 @@ export default async (req, res) => {
await Data.createTwitterToken({ token: authToken, tokenSecret: authSecretToken });
res.json({ authToken });
} catch (e) {
console.log("error", e);
Logging.error("error", e);
res.status(500).send({ decorator: "SERVER_TWITTER_REQUEST_TOKEN_FAILED", error: true });
}
};

View File

@ -39,7 +39,7 @@ export default async (req, res) => {
error: true,
});
}
console.log("before get slates by user id");
let slates = await Data.getSlatesByUserId({
ownerId: user.id,
includeFiles: true,

View File

@ -2,6 +2,7 @@ import * as Data from "~/node_common/data";
import * as Validations from "~/common/validations";
import * as Strings from "~/common/strings";
import * as Environment from "~/node_common/environment";
import * as Logging from "~/common/logging";
export default async (req, res) => {
if (!Strings.isEmpty(Environment.ALLOWED_HOST) && req.headers.host !== Environment.ALLOWED_HOST) {
@ -14,7 +15,7 @@ export default async (req, res) => {
try {
user = await Data.getUserByEmail({ email: username });
} catch (e) {
console.log(e);
Logging.error(e);
}
} else {
try {
@ -22,7 +23,7 @@ export default async (req, res) => {
username: req.body.data.username.toLowerCase(),
});
} catch (e) {
console.log(e);
Logging.error(e);
}
}

View File

@ -6,6 +6,7 @@ import * as Validations from "~/common/validations";
import * as Social from "~/node_common/social";
import * as ViewerManager from "~/node_common/managers/viewer";
import * as SearchManager from "~/node_common/managers/search";
import * as Logging from "~/common/logging";
import BCrypt from "bcrypt";
@ -73,7 +74,7 @@ export default async (req, res) => {
bucketName: "data",
});
} catch (e) {
console.log(e);
Logging.error(e);
Social.sendTextileSlackMessage({
file: "/pages/api/users/update.js",
user,
@ -91,7 +92,7 @@ export default async (req, res) => {
req.body.data.config
);
} catch (e) {
console.log(e);
Logging.error(e);
Social.sendTextileSlackMessage({
file: "/pages/api/users/update.js",
user,

View File

@ -4,6 +4,7 @@ import * as Strings from "~/common/strings";
import * as Environment from "~/node_common/environment";
import * as Utilities from "~/node_common/utilities";
import * as EmailManager from "~/node_common/managers/emails";
import * as Logging from "~/common/logging";
// NOTE(amine): this endpoint is rate limited in ./server.js,
export default async (req, res) => {
@ -71,6 +72,6 @@ export default async (req, res) => {
token: verification.sid,
});
} catch (e) {
console.log(e);
Logging.error(e);
}
};

View File

@ -2,6 +2,7 @@ import * as React from "react";
import * as Actions from "~/common/actions";
import * as Events from "~/common/custom-events";
import * as Utilities from "~/common/utilities";
import * as Logging from "~/common/logging";
const AUTH_STATE_GRAPH = {
initial: {
@ -303,7 +304,7 @@ export const useTwitter = ({ onAuthenticate, goToTwitterSignupScene }) => {
goToTwitterSignupScene({ twitterEmail: response.email });
} catch (e) {
// TODO failure
console.log("error", e);
Logging.error("error", e);
if (popup) popup.close();
setIsLoggingIn(false);
}

View File

@ -165,8 +165,6 @@ export default class SceneFilesFolder extends React.Component {
return filtered.publicFiles;
} else if (filter === "PRIVATE") {
return filtered.privateFiles;
} else {
console.log("unusable privacy param");
}
};

View File

@ -1,13 +1,15 @@
import * as Logging from "~/common/logging";
import configs from "~/knexfile";
import knex from "knex";
const envConfig = configs["development"];
console.log(`SETUP: database`, envConfig);
Logging.log(`SETUP: database`, envConfig);
const db = knex(envConfig);
console.log(`RUNNING: adjust.js`);
Logging.log(`RUNNING: adjust.js`);
const editUsersTable1 = db.schema.table("users", function (table) {
table.integer("authVersion").notNullable().defaultTo(1);
@ -44,5 +46,5 @@ Promise.all([editVerificationTable]);
// Promise.all([editUsersTable1]);
// Promise.all([editUsersTable2, editVerificationTable, editTwitterTokenTable]);
console.log(`FINISHED: adjust.js`);
console.log(` CTRL +C to return to terminal.`);
Logging.log(`FINISHED: adjust.js`);
Logging.log(` CTRL +C to return to terminal.`);

View File

@ -1,30 +1,31 @@
import * as Logging from "~/common/logging";
import * as Data from "~/node_common/data";
import configs from "~/knexfile";
import knex from "knex";
import * as Data from "~/node_common/data";
import { deleteUser } from "~/pages/api/users/delete";
const envConfig = configs["development"];
const db = knex(envConfig);
console.log(`RUNNING: delete-user.js`);
Logging.log(`RUNNING: delete-user.js`);
const run = async () => {
const user = await Data.getUserByUsername({
username: process.argv[3],
});
console.log(user);
Logging.log(user);
if (user) {
console.log(`deleting ${user.username}`);
Logging.log(`deleting ${user.username}`);
await deleteUser(user);
}
console.log(`FINISHED: delete-user.js`);
console.log(` CTRL +C to return to terminal.`);
Logging.log(`FINISHED: delete-user.js`);
Logging.log(` CTRL +C to return to terminal.`);
};
run();

View File

@ -1,13 +1,15 @@
import * as Logging from "~/common/logging";
import configs from "~/knexfile";
import knex from "knex";
const envConfig = configs["development"];
console.log(`SETUP: database`, envConfig);
Logging.log(`SETUP: database`, envConfig);
const db = knex(envConfig);
console.log(`RUNNING: drop-database.js`);
Logging.log(`RUNNING: drop-database.js`);
Promise.all([
db.schema.dropTable("users"),
@ -25,5 +27,5 @@ Promise.all([
db.schema.dropTable("likes"),
]);
console.log(`FINISHED: drop-database.js`);
console.log(` CTRL +C to return to terminal.`);
Logging.log(`FINISHED: drop-database.js`);
Logging.log(` CTRL +C to return to terminal.`);

View File

@ -2,6 +2,7 @@ import configs from "~/knexfile";
import knex from "knex";
import { v4 as uuid } from "uuid";
import * as Logging from "~/common/logging";
import * as Utilities from "~/node_common/utilities";
import * as Data from "~/node_common/data";
import * as Strings from "~/common/strings";
@ -11,7 +12,7 @@ const envConfig = configs["development"];
const DB = knex(envConfig);
console.log(`RUNNING: files-migration.js`);
Logging.log(`RUNNING: files-migration.js`);
// MARK: - check what parameters are in each table
@ -44,9 +45,9 @@ const printUsersTable = async () => {
}
}
}
console.log({ dataParams: Object.keys(dataParams) });
console.log({ fileParams: Object.keys(fileParams) });
console.log({ coverParams: Object.keys(coverParams) });
Logging.log({ dataParams: Object.keys(dataParams) });
Logging.log({ fileParams: Object.keys(fileParams) });
Logging.log({ coverParams: Object.keys(coverParams) });
};
const printSlatesTable = async () => {
@ -78,9 +79,9 @@ const printSlatesTable = async () => {
}
}
}
console.log({ dataParams: Object.keys(dataParams) });
console.log({ fileParams: Object.keys(fileParams) });
console.log({ coverParams: Object.keys(coverParams) });
Logging.log({ dataParams: Object.keys(dataParams) });
Logging.log({ fileParams: Object.keys(fileParams) });
Logging.log({ coverParams: Object.keys(coverParams) });
};
// MARK: - add/modify tables
@ -168,7 +169,7 @@ const addTables = async () => {
table.uuid("userId").references("id").inTable("users").alter();
});
console.log("finished adding tables");
Logging.log("finished adding tables");
};
// MARK: - populate new tables
@ -198,8 +199,8 @@ const migrateUsersTable = async (testing = false) => {
cid = file.ipfs;
}
if (!cid) {
console.log("file does not have cid or ipfs");
console.log(file);
Logging.log("file does not have cid or ipfs");
Logging.log(file);
return;
}
let id = file.id.replace("data-", "");
@ -210,7 +211,7 @@ const migrateUsersTable = async (testing = false) => {
//NOTE(martina): to make sure there are no duplicate cids in the user's files
if (libraryCids[cid]) {
console.log(`skipped duplicate cid ${cid} in user ${user.username} files`);
Logging.log(`skipped duplicate cid ${cid} in user ${user.username} files`);
continue;
}
libraryCids[cid] = true;
@ -219,7 +220,7 @@ const migrateUsersTable = async (testing = false) => {
const hasConflict = conflicts.includes(id);
conflicts.push(id);
if (hasConflict) {
console.log(`changing id for saved copy ${id} in ${user.username} files`);
Logging.log(`changing id for saved copy ${id} in ${user.username} files`);
id = uuid();
}
@ -264,7 +265,7 @@ const migrateUsersTable = async (testing = false) => {
newFiles.push(newFile);
}
if (testing) {
// console.log(newFiles);
// Logging.log(newFiles);
} else {
await DB.insert(newFiles).into("files");
}
@ -276,11 +277,11 @@ const migrateUsersTable = async (testing = false) => {
}
}
if (count % 100 === 0) {
console.log(`${count} users done`);
Logging.log(`${count} users done`);
}
count += 1;
}
console.log("finished migrating users table");
Logging.log("finished migrating users table");
};
const migrateSlatesTable = async (testing = false) => {
@ -288,7 +289,7 @@ const migrateSlatesTable = async (testing = false) => {
let count = 0;
for (let slate of slates) {
if (!slate.data.ownerId) {
console.log({ slateMissingOwnerId: slate });
Logging.log({ slateMissingOwnerId: slate });
continue;
}
if (slate.data.objects) {
@ -303,7 +304,7 @@ const migrateSlatesTable = async (testing = false) => {
for (let file of slate.data.objects) {
if (!file.url || !file.ownerId || !file.id) {
if (!file.ownerId) {
console.log({ fileMissingOwnerId: file });
Logging.log({ fileMissingOwnerId: file });
}
continue;
}
@ -311,7 +312,7 @@ const migrateSlatesTable = async (testing = false) => {
//NOTE(martina): make sure there are no duplicated cids in a slate
if (slateCids[cid]) {
console.log(`found duplicate file cid ${cid} in slate`);
Logging.log(`found duplicate file cid ${cid} in slate`);
continue;
}
slateCids[cid] = true;
@ -338,7 +339,7 @@ const migrateSlatesTable = async (testing = false) => {
!Strings.isEmpty(file.author))
) {
if (!matchingFile.data) {
console.log("Matching file did not have data");
Logging.log("Matching file did not have data");
continue;
}
@ -355,7 +356,7 @@ const migrateSlatesTable = async (testing = false) => {
},
});
} else {
console.log({
Logging.log({
data: {
...matchingFile.data,
name: file.title ? file.title.substring(0, 255) : "",
@ -380,18 +381,18 @@ const migrateSlatesTable = async (testing = false) => {
}
}
if (count % 100 === 0) {
console.log(`${count} slates done`);
Logging.log(`${count} slates done`);
}
// if (testing) {
// if (count >= 50) {
// return;
// }
// console.log(objects);
// Logging.log(objects);
// }
count += 1;
}
}
console.log("finished migrating slates table");
Logging.log("finished migrating slates table");
};
//make a function that double checks correctness: finds any duplicate fileId, ownerId in files. and any duplicate fileid slateid in slate_files
@ -421,7 +422,7 @@ const migrateActivityTable = async (testing = false) => {
slateId = event.data.context?.slate?.id;
fileId = event.data.context?.file?.id;
if (!slateId || !fileId) {
// console.log(event.data);
// Logging.log(event.data);
continue;
}
fileId = fileId.replace("data-", "");
@ -438,12 +439,12 @@ const migrateActivityTable = async (testing = false) => {
createdAt,
}).into("activity");
} catch (e) {
console.log(e);
Logging.log(e);
}
}
if (testing) {
console.log({
Logging.log({
id,
ownerId,
userId,
@ -458,7 +459,7 @@ const migrateActivityTable = async (testing = false) => {
count += 1;
}
}
console.log("finished migrating activity table");
Logging.log("finished migrating activity table");
};
// MARK: - adding new fields and reformatting
@ -469,14 +470,14 @@ const modifySlatesTable = async (testing = false) => {
const id = slate.id;
const ownerId = slate.data.ownerId;
if (!ownerId) {
console.log(slate);
Logging.log(slate);
continue;
}
if (!testing) {
await DB.from("slates").where("id", id).update({ ownerId, isPublic: slate.data.public });
}
}
console.log("finished modify slates table");
Logging.log("finished modify slates table");
};
const modifyUsersTable = async (testing = false) => {
@ -502,12 +503,12 @@ const modifyUsersTable = async (testing = false) => {
if (count === 10) {
return;
}
console.log(data);
Logging.log(data);
} else {
await Data.updateUserById({ id, data });
}
}
console.log("finished modify users table");
Logging.log("finished modify users table");
};
// MARK: - deleting original data source
@ -525,7 +526,7 @@ const cleanUsersTable = async () => {
onboarding: user.data.onboarding,
status: user.data.status,
};
// console.log(data);
// Logging.log(data);
await DB.from("users").where("id", id).update({ data });
}
};
@ -551,8 +552,8 @@ const cleanSlatesTable = async () => {
preview: slate.data.preview,
tags: slate.data.tags,
};
// console.log(layouts?.layout);
// console.log(data);
// Logging.log(layouts?.layout);
// Logging.log(data);
await DB.from("slates").where("id", id).update({ data });
}
};
@ -569,11 +570,11 @@ const dropOldTables = async () => {
const wipeNewTables = async () => {
let numDeleted = await DB("slate_files").del();
console.log(`${numDeleted} deleted from slate_files`);
Logging.log(`${numDeleted} deleted from slate_files`);
numDeleted = await DB("activity").del();
console.log(`${numDeleted} deleted from activity`);
Logging.log(`${numDeleted} deleted from activity`);
numDeleted = await DB("files").del();
console.log(`${numDeleted} deleted from files`);
Logging.log(`${numDeleted} deleted from files`);
};
const runScript = async () => {
@ -603,7 +604,7 @@ const runScript = async () => {
// await cleanSlatesTable();
await dropOldTables();
console.log("Finished running. Hit CTRL + C to quit");
Logging.log("Finished running. Hit CTRL + C to quit");
};
runScript();

View File

@ -1,3 +1,5 @@
import * as Logging from "~/common/logging";
// Source
// https://github.com/Data-Wrangling-with-JavaScript/nodejs-memory-test/blob/master/index.js
// Small program to test the maximum amount of allocations in multiple blocks.
@ -8,13 +10,13 @@
// Allocate a certain size to test if it can be done.
//
function alloc(size) {
const numbers = size / 8;
const arr = [];
arr.length = numbers; // Simulate allocation of 'size' bytes.
for (let i = 0; i < numbers; i++) {
arr[i] = i;
}
return arr;
const numbers = size / 8;
const arr = [];
arr.length = numbers; // Simulate allocation of 'size' bytes.
for (let i = 0; i < numbers; i++) {
arr[i] = i;
}
return arr;
}
//
@ -26,38 +28,33 @@ const allocations = [];
// Allocate successively larger sizes, doubling each time until we hit the limit.
//
function allocToMax() {
console.log("[ starting memory burn ]");
Logging.log("[ starting memory burn ]");
const field = "heapUsed";
const field = "heapUsed";
const mu = process.memoryUsage();
Logging.log(mu);
const gbStart = mu[field] / 1024 / 1024 / 1024;
Logging.log(`[ memory burn ] ${Math.round(gbStart * 100) / 100} GB`);
let allocationStep = 100 * 1024;
while (true) {
// Allocate memory.
const allocation = alloc(allocationStep);
// Allocate and keep a reference so the allocated memory isn't garbage collected.
allocations.push(allocation);
// Check how much memory is now allocated.
const mu = process.memoryUsage();
console.log(mu);
const gbStart = mu[field] / 1024 / 1024 / 1024;
console.log(
`[ memory burn ] ${Math.round(gbStart * 100) / 100} GB`
);
let allocationStep = 100 * 1024;
while (true) {
// Allocate memory.
const allocation = alloc(allocationStep);
// Allocate and keep a reference so the allocated memory isn't garbage collected.
allocations.push(allocation);
// Check how much memory is now allocated.
const mu = process.memoryUsage();
const mbNow = mu[field] / 1024 / 1024 / 1024;
//console.log(`Total allocated ${Math.round(mbNow * 100) / 100} GB`);
console.log(
`[ allocated since start ] ${Math.round((mbNow - gbStart) * 100) /
100} GB`
);
// Infinite loop, never get here.
}
const mbNow = mu[field] / 1024 / 1024 / 1024;
//Logging.log(`Total allocated ${Math.round(mbNow * 100) / 100} GB`);
Logging.log(`[ allocated since start ] ${Math.round((mbNow - gbStart) * 100) / 100} GB`);
// Infinite loop, never get here.
}
// Infinite loop, never get here.
}
allocToMax();

View File

@ -1,7 +1,9 @@
import configs from "~/knexfile";
import knex from "knex";
import { v4 as uuid } from "uuid";
import * as Logging from "~/common/logging";
import * as Utilities from "~/node_common/utilities";
import * as Data from "~/node_common/data";
import * as Strings from "~/common/strings";
@ -11,7 +13,7 @@ const envConfig = configs["development"];
const DB = knex(envConfig);
console.log(`RUNNING: files-migration.js`);
Logging.log(`RUNNING: files-migration.js`);
const makeFilesPublic = async () => {
let publicFiles = await DB.from("files")
@ -31,9 +33,9 @@ const getSlateSubscriberAndFileCount = async () => {
subscriberCount = subscriberCount.pop().count;
let fileCount = await DB("slate_files").where("slateId", slate.id).count();
fileCount = fileCount.pop().count;
// console.log(slate.id);
// console.log(subscriberCount);
// console.log(fileCount);
// Logging.log(slate.id);
// Logging.log(subscriberCount);
// Logging.log(fileCount);
await DB("slates").where("id", slate.id).update({
subscriberCount,
@ -51,10 +53,10 @@ const getUserFollowerAndFileAndSlateCount = async () => {
fileCount = fileCount.pop().count;
let slateCount = await DB("slates").where({ ownerId: user.id, isPublic: true }).count();
slateCount = slateCount.pop().count;
console.log(user.id);
console.log(followerCount);
console.log(fileCount);
console.log(slateCount);
Logging.log(user.id);
Logging.log(followerCount);
Logging.log(fileCount);
Logging.log(slateCount);
// await DB("users").where("id", user.id).update({
// followerCount,
// fileCount,
@ -68,7 +70,7 @@ const runScript = async () => {
// await getSlateSubscriberAndFileCount();
await getUserFollowerAndFileAndSlateCount();
console.log("Finished running. Hit CTRL + C to quit");
Logging.log("Finished running. Hit CTRL + C to quit");
};
runScript();

View File

@ -2,6 +2,7 @@ import configs from "~/knexfile";
import knex from "knex";
import { v4 as uuid } from "uuid";
import * as Logging from "~/common/logging";
import * as Utilities from "~/node_common/utilities";
import * as Data from "~/node_common/data";
import * as Strings from "~/common/strings";
@ -11,7 +12,7 @@ const envConfig = configs["production"];
const DB = knex(envConfig);
console.log(`RUNNING: files-migration.js`);
Logging.log(`RUNNING: files-migration.js`);
const saveCopyReposts = async () => {
let repostedFiles = await DB.column(
@ -28,10 +29,10 @@ const saveCopyReposts = async () => {
.join("files", "files.id", "=", "slate_files.fileId")
.join("users", "users.id", "=", "slates.ownerId")
.whereRaw("?? != ??", ["files.ownerId", "slates.ownerId"]);
// console.log(repostedFiles.length);
// Logging.log(repostedFiles.length);
for (let item of repostedFiles) {
console.log(item);
Logging.log(item);
// continue;
let user = { data: item.data };
let { buckets, bucketKey, bucketRoot } = await Utilities.getBucketAPIFromUserToken({
@ -46,7 +47,7 @@ const saveCopyReposts = async () => {
cid: item.cid,
});
} catch (e) {
console.log(e);
Logging.log(e);
}
const duplicateFiles = await Data.getFilesByCids({
@ -56,7 +57,7 @@ const saveCopyReposts = async () => {
if (duplicateFiles.length) {
if (!duplicateFiles[0].isPublic && item.isPublic) {
console.log("UPDATE PUBLIC FOR FILE");
Logging.log("UPDATE PUBLIC FOR FILE");
await DB.from("files").where("id", item.fileId).update({ isPublic: true });
}
} else {
@ -83,14 +84,14 @@ const removeReposts = async () => {
})
.del()
.returning("*");
console.log(repostedFiles);
Logging.log(repostedFiles);
};
const runScript = async () => {
await saveCopyReposts();
// await removeReposts();
console.log("Finished running. Hit CTRL + C to quit");
Logging.log("Finished running. Hit CTRL + C to quit");
};
runScript();

View File

@ -1,13 +1,15 @@
import configs from "~/knexfile";
import knex from "knex";
import * as Logging from "~/common/logging";
const envConfig = configs["development"];
console.log(`SETUP: database`, envConfig);
Logging.log(`SETUP: database`, envConfig);
const db = knex(envConfig);
console.log(`RUNNING: seed-database.js`);
Logging.log(`RUNNING: seed-database.js`);
// --------------------------
// SCRIPTS
@ -180,5 +182,5 @@ Promise.all([
createTwitterTokensTable,
]);
console.log(`FINISHED: seed-database.js`);
console.log(` CTRL +C to return to terminal.`);
Logging.log(`FINISHED: seed-database.js`);
Logging.log(` CTRL +C to return to terminal.`);

View File

@ -1,15 +1,17 @@
import configs from "~/knexfile";
import knex from "knex";
import * as Logging from "~/common/logging";
const envConfig = configs["development"];
console.log(`SETUP: database`, envConfig);
Logging.log(`SETUP: database`, envConfig);
const db = knex(envConfig);
console.log(`RUNNING: setup-database.js`);
Logging.log(`RUNNING: setup-database.js`);
Promise.all([db.raw('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"')]);
console.log(`FINISHED: setup-database.js`);
console.log(` CTRL +C to return to terminal.`);
Logging.log(`FINISHED: setup-database.js`);
Logging.log(` CTRL +C to return to terminal.`);

View File

@ -3,11 +3,12 @@ import knex from "knex";
import * as Data from "~/node_common/data";
import * as Strings from "~/common/strings";
import * as Logging from "~/common/logging";
const envConfig = configs["development"];
const db = knex(envConfig);
console.log(`RUNNING: worker-analytics.js`);
Logging.log(`RUNNING: worker-analytics.js`);
function sortObject(obj) {
var arr = [];
@ -49,13 +50,13 @@ const run = async () => {
userMap = userMap.map((each, index) => {
return { ...each, index, value: Strings.bytesToSize(each.value) };
});
console.log(userMap);
console.log("TOTAL USER COUNT", count);
console.log("TOTAL BYTES", bytes);
console.log("TOTAL BYTES (CONVERTED)", Strings.bytesToSize(bytes));
Logging.log(userMap);
Logging.log("TOTAL USER COUNT", count);
Logging.log("TOTAL BYTES", bytes);
Logging.log("TOTAL BYTES (CONVERTED)", Strings.bytesToSize(bytes));
};
// run();
console.log(`FINISHED: worker-analytics.js`);
console.log(` CTRL +C to return to terminal.`);
Logging.log(`FINISHED: worker-analytics.js`);
Logging.log(` CTRL +C to return to terminal.`);

View File

@ -3,6 +3,7 @@ import knex from "knex";
import fs from "fs-extra";
import "isomorphic-fetch";
import * as Logging from "~/common/logging";
import * as Environment from "~/node_common/environment";
import * as Data from "~/node_common/data";
import * as Utilities from "~/node_common/utilities";
@ -36,7 +37,7 @@ const TEXTILE_KEY_INFO = {
secret: Environment.TEXTILE_HUB_SECRET,
};
console.log(`RUNNING: worker-heavy-stones.js`);
Logging.log(`RUNNING: worker-heavy-stones.js`);
const delay = async (waitMs) => {
return await new Promise((resolve) => setTimeout(resolve, waitMs));
@ -220,9 +221,9 @@ const run = async () => {
const dealToSave = storageDeals[d];
Logs.note(`Saving ${dealToSave.dealId} ...`);
console.log(dealToSave);
Logging.log(dealToSave);
const existing = await db.select("*").from("deals").where(hasDealId(dealToSave.dealId));
console.log(existing);
Logging.log(existing);
if (existing && !existing.error && existing.length) {
Logs.error(`${dealToSave.dealId} is already saved.`);
@ -272,8 +273,8 @@ const run = async () => {
// NOTE(jim): Determine open deals
try {
const { current, history } = await buckets.archives(keyBucket.key);
console.log(current);
console.log(history);
Logging.log(current);
Logging.log(history);
} catch (e) {
Logs.error(e.message);
continue;
@ -312,8 +313,8 @@ const run = async () => {
// NOTE(jim): Determine open deals
try {
const { current, history } = await buckets.archives(keyBucket.key);
console.log(current);
console.log(history);
Logging.log(current);
Logging.log(history);
} catch (e) {
Logs.error(e.message);
continue;
@ -464,8 +465,8 @@ const run = async () => {
Logs.task(`Show us the history!`);
try {
const { current, history } = await buckets.archives(targetBucket.key);
console.log(current);
console.log(history);
Logging.log(current);
Logging.log(history);
} catch (e) {
Logs.error(e.message);
continue;
@ -482,16 +483,16 @@ const run = async () => {
}
}
console.log("\n");
Logging.log("\n");
}
Logs.task(`total storage per run: ${Strings.bytesToSize(bytes)}`);
Logs.task(`total storage per run (with replication x5): ${Strings.bytesToSize(bytes * 5)}`);
Logs.task(`creating slate-storage-addresses.json`);
console.log(`${STORAGE_BOT_NAME} finished. \n\n`);
console.log(`FINISHED: worker-heavy-stones.js`);
console.log(` CTRL +C to return to terminal.`);
Logging.log(`${STORAGE_BOT_NAME} finished. \n\n`);
Logging.log(`FINISHED: worker-heavy-stones.js`);
Logging.log(` CTRL +C to return to terminal.`);
};
run();

View File

@ -4,7 +4,7 @@ import * as Utilities from "~/node_common/utilities";
import * as Serializers from "~/node_common/serializers";
import * as ViewerManager from "~/node_common/managers/viewer";
import * as Websocket from "~/node_common/nodejs-websocket";
import * as NodeLogging from "~/node_common/node-logging";
import * as Logging from "~/common/logging";
import * as Validations from "~/common/validations";
import * as Window from "~/common/window";
import * as Strings from "~/common/strings";
@ -208,7 +208,6 @@ app.prepare().then(async () => {
if (!redirected) {
page.params = req.query;
}
console.log({ page });
if (!page) {
return handler(req, res, req.url, {
@ -543,14 +542,14 @@ app.prepare().then(async () => {
if (e) throw e;
Websocket.create();
NodeLogging.log(`started on http://localhost:${Environment.PORT}`);
Logging.log(`started on http://localhost:${Environment.PORT}`);
exploreSlates = await fetchExploreSlates();
const filecoinNumber = new FilecoinNumber("10000", "attoFil");
console.log(`Testing Values: ${filecoinNumber.toPicoFil()} PICO FIL`);
console.log(`Testing Values: ${filecoinNumber.toAttoFil()} ATTO FIL`);
console.log(`Testing Values: ${filecoinNumber.toFil()} FIL`);
Logging.log(`Testing Values: ${filecoinNumber.toPicoFil()} PICO FIL`);
Logging.log(`Testing Values: ${filecoinNumber.toAttoFil()} ATTO FIL`);
Logging.log(`Testing Values: ${filecoinNumber.toFil()} FIL`);
});
});