From 55d9edb7e76e0f3035798ba8e87d025d04344488 Mon Sep 17 00:00:00 2001 From: Moon Man Date: Mon, 1 Jan 2024 08:23:05 -0500 Subject: [PATCH] rm user function aliases --- src/activity.ts | 2 +- src/command.ts | 2 +- src/follower.ts | 2 +- src/index.ts | 4 ++-- src/net.ts | 2 +- src/outbox.ts | 2 +- src/user.ts | 10 +++++----- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/activity.ts b/src/activity.ts index 58ca89e..edc221e 100644 --- a/src/activity.ts +++ b/src/activity.ts @@ -5,7 +5,7 @@ import { User, getByActor } from "./user.js"; import { fillRoute, reverseRoute } from "./router.js"; import { streamToString, hashDigest } from "./util.js"; import { signedFetch, SignedInit, getActor } from "./net.js"; -import { getById as getUserById, keyIdFromNickname } from "./user.js"; +import { getUserById, keyIdFromNickname } from "./user.js"; import parser from "activitypub-http-signatures"; import type { Request, Response } from "express"; import { addFollower } from "./follower.js"; diff --git a/src/command.ts b/src/command.ts index 1838814..710995f 100644 --- a/src/command.ts +++ b/src/command.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import markdownit from 'markdown-it' import { slugRegex } from "./article.js"; -import { newUser, get as getUserByNickname, getFollowerInboxes, keyIdFromNickname } from "./user.js"; +import { newUser, getUserByNickname, getFollowerInboxes, keyIdFromNickname } from "./user.js"; import { insert as insertArticle } from "./article.js"; import { add as addToOutbox } from "./outbox.js"; import { createArticleActivity, sendAll } from "./activity.js"; diff --git a/src/follower.ts b/src/follower.ts index 6b65f7d..0904de0 100644 --- a/src/follower.ts +++ b/src/follower.ts @@ -2,7 +2,7 @@ import { TYPE } from "./activity.js"; import { CollectionEntry, orderedCollection } from "./collection.js"; import db from "./db.js"; import { fillRoute } from "./router.js"; -import { get as getUserByNickname } from "./user.js"; +import { getUserByNickname } from "./user.js"; import { Request, Response } from "express"; export interface Follower { diff --git a/src/index.ts b/src/index.ts index d87c463..2ad0a17 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import express, { Request } from "express"; import bodyParser from "body-parser"; import { toCollection as getOutbox } from "./outbox.js"; -import { getById as getUserById, getNickname, get as getUserByNickname, getId as getUserId, User } from "./user.js"; +import { getUserById, getUserNicknameById, getUserByNickname, User } from "./user.js"; import { Routes } from "./router.js"; import { getBySlug as getArticleBySlug, getById, getByUserId, getAll as getAllArticles } from "./article.js"; import { userToPerson, TYPE as ACTIVITYPUB_TYPE, handleInboxPost, createArticleObject, CONTEXT, createArticleActivity } from "./activity.js"; @@ -58,7 +58,7 @@ app.get(Routes.object, async (req, res) => { "application/ld+json", "json" ])) { - const nickname = await getNickname(article.users_id) as string; + const nickname = await getUserNicknameById(article.users_id) as string; const obj = createArticleObject(article, nickname); obj["@context"] = CONTEXT; diff --git a/src/net.ts b/src/net.ts index f5fdc40..5543cec 100644 --- a/src/net.ts +++ b/src/net.ts @@ -6,7 +6,7 @@ import { actorSchema } from "./activitypub_types.js"; import type { Actor } from "./activitypub_types.js"; import type { Request, Response } from "express"; import { fillRoute } from "./router.js"; -import { get as getUserByNickname } from "./user.js"; +import { getUserByNickname } from "./user.js"; export const flattenHeaders = (headers: Record) => Object.entries(headers).map(([key, value]) => `${key}: ${value}`); diff --git a/src/outbox.ts b/src/outbox.ts index bb91369..66824a4 100644 --- a/src/outbox.ts +++ b/src/outbox.ts @@ -1,6 +1,6 @@ import db from "./db.js"; import { z } from "zod"; -import { get as getUserByNickname } from "./user.js"; +import { getUserByNickname } from "./user.js"; import { fillRoute } from "./router.js"; import { getByUserId as getArticlesByUserId, getById as getArticleById, Article } from "./article.js"; import { createArticleActivity, deleteArticleActivity } from "./activity.js"; diff --git a/src/user.ts b/src/user.ts index 005a9d6..d1c185c 100644 --- a/src/user.ts +++ b/src/user.ts @@ -27,13 +27,13 @@ export const zUser = z.object({ export type User = z.infer; -export const get = async (nickname: string) => +export const getUserByNickname = async (nickname: string) => db("users") .where("nickname", nickname) .first() ; -export const getById = async (id: number) => +export const getUserById = async (id: number) => db("users") .where("id", id) .first() @@ -45,12 +45,12 @@ export const getByActor = async (actor: string) => { const matchArray = actor.match(EXTRACT_NICKNAME); if (matchArray) { const nickname = matchArray[1]; - return get(nickname); + return getUserByNickname(nickname); } else return null; }; -export const getNickname = async (userId: number): Promise => +export const getUserNicknameById = async (userId: number): Promise => db("users") .select("nickname") .where("id", userId) @@ -58,7 +58,7 @@ export const getNickname = async (userId: number): Promise => .then((rec) => !!rec ? rec.nickname : null) ; -export const getId = async (nickname: string): Promise => +export const getUserIdByNickname = async (nickname: string): Promise => db("users") .select("id") .where("nickname", nickname)