stacker.news/prisma/schema.prisma

744 lines
26 KiB
Plaintext
Raw Normal View History

2023-07-26 16:01:31 +00:00
generator client {
provider = "prisma-client-js"
}
2021-03-25 19:29:24 +00:00
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
2023-06-20 01:26:34 +00:00
model Snl {
id Int @id @default(autoincrement())
live Boolean @default(false)
}
2021-03-25 19:29:24 +00:00
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
name String? @unique(map: "users.name_unique") @db.Citext
email String? @unique(map: "users.email_unique")
emailVerified DateTime? @map("email_verified")
image String?
msats BigInt @default(0)
freeComments Int @default(5)
freePosts Int @default(2)
checkedNotesAt DateTime?
foundNotesAt DateTime?
pubkey String? @unique(map: "users.pubkey_unique")
tipDefault Int @default(100)
bioId Int?
inviteId String?
tipPopover Boolean @default(false)
upvotePopover Boolean @default(false)
trust Float @default(0)
lastSeenAt DateTime?
stackedMsats BigInt @default(0)
noteAllDescendants Boolean @default(true)
noteDeposits Boolean @default(true)
noteEarning Boolean @default(true)
noteInvites Boolean @default(true)
noteItemSats Boolean @default(true)
noteMentions Boolean @default(true)
noteForwardedSats Boolean @default(true)
lastCheckedJobs DateTime?
noteJobIndicator Boolean @default(true)
photoId Int?
upvoteTrust Float @default(0)
hideInvoiceDesc Boolean @default(false)
wildWestMode Boolean @default(false)
greeterMode Boolean @default(false)
fiatCurrency String @default("USD")
withdrawMaxFeeDefault Int @default(10)
autoDropBolt11s Boolean @default(false)
hideFromTopUsers Boolean @default(false)
turboTipping Boolean @default(false)
imgproxyOnly Boolean @default(false)
hideWalletBalance Boolean @default(false)
referrerId Int?
nostrPubkey String?
nostrAuthPubkey String? @unique(map: "users.nostrAuthPubkey_unique")
nostrCrossposting Boolean @default(false)
slashtagId String? @unique(map: "users.slashtagId_unique")
noteCowboyHat Boolean @default(true)
streak Int?
subs String[]
hideCowboyHat Boolean @default(false)
Bookmarks Bookmark[]
Donation Donation[]
Earn Earn[]
invites Invite[] @relation("Invites")
invoices Invoice[]
items Item[] @relation("UserItems")
actions ItemAct[]
mentions Mention[]
messages Message[]
PollVote PollVote[]
PushSubscriptions PushSubscription[]
ReferralAct ReferralAct[]
Streak Streak[]
Subscriptions Subscription[]
ThreadSubscriptions ThreadSubscription[]
Upload Upload[] @relation("Uploads")
nostrRelays UserNostrRelay[]
withdrawls Withdrawl[]
bio Item? @relation(fields: [bioId], references: [id])
invite Invite? @relation(fields: [inviteId], references: [id])
photo Upload? @relation(fields: [photoId], references: [id])
referrer User? @relation("referrals", fields: [referrerId], references: [id])
referrees User[] @relation("referrals")
Account Account[]
Session Session[]
itemForwards ItemForward[]
hideBookmarks Boolean @default(false)
followers UserSubscription[] @relation("follower")
followees UserSubscription[] @relation("followee")
hideWelcomeBanner Boolean @default(false)
diagnostics Boolean @default(false)
hideIsContributor Boolean @default(false)
muters Mute[] @relation("muter")
muteds Mute[] @relation("muted")
ArcOut Arc[] @relation("fromUser")
ArcIn Arc[] @relation("toUser")
2023-11-21 23:32:22 +00:00
Sub Sub[]
SubAct SubAct[]
2022-08-06 22:03:57 +00:00
Image uploads (#576) * Add icon to add images * Open file explorer to select image * Upload images to S3 on selection * Show uploaded images below text input * Link and remove image * Fetch unsubmitted images from database * Mark S3 images as submitted in imgproxy job * Add margin-top * Mark images as submitted on client after successful mutation * Also delete objects in S3 * Allow items to have multiple uploads linked * Overwrite old avatar * Add fees for presigned URLs * Use Github style upload * removed upfront fees * removed images provider since we no longer need to keep track of unsubmitted images on the client * removed User.images resolver * removed deleteImage mutation * use Github style upload where it shows ![Uploading <filename>...]() first and then replaces that with ![<filename>](<url>) after successful upload * Add Upload.paid boolean column One item can have multiple images linked to it, but an image can also be used in multiple items (many-to-many relation). Since we don't really care to which item an image is linked and vice versa, we just use a boolean column to mark if an image was already paid for. This makes fee calculation easier since no JOINs are required. * Add image fees during item creation/update * we calculate image fees during item creation and update now * function imageFees returns queries which deduct fees from user and mark images as paid + fees * queries need to be run inside same transaction as item creation/update * Allow anons to get presigned URLs * Add comments regarding avatar upload * Use megabytes in error message * Remove unnecessary avatar check during image fees calculation * Show image fees in frontend * Also update image fees on blur This makes sure that the images fees reflect the current state. For example, if an image was removed. We could also add debounced requests. * Show amount of unpaid images in receipt * Fix fees in sats deducted from msats * Fix algebraic order of fees Spam fees must come immediately after the base fee since it multiplies the base fee. * Fix image fees in edit receipt * Fix stale fees shown If we pay for an image and then want to edit the comment, the cache might return stale date; suggesting we didn't pay for the existing image yet. * Add 0 base fee in edit receipt * Remove 's' from 'image fees' in receipts * Remove unnecessary async * Remove 'Uploading <name>...' from text input on error * Support upload of multiple files at once * Add schedule to delete unused images * Fix image fee display in receipts * Use Drag and Drop API for image upload * Remove dragOver style on drop * Increase max upload size to 10MB to allow HQ camera pictures * Fix free upload quota * Fix stale image fees served * Fix bad image fee return statements * Fix multiplication with feesPerImage * Fix NULL returned for size24h, sizeNow * Remove unnecessary text field in query * refactor: Unify <ImageUpload> and <Upload> component * Add avatar cache busting using random query param * Calculate image fee info in postgres function * we now calculate image fee info in a postgres function which is much cleaner * we use this function inside `create_item` and `update_item`: image fees are now deducted in the same transaction as creating/updating the item! * reversed changes in `serializeInvoiceable` * Fix line break in receipt * Update upload limits * Add comment about `e.target.value = null` * Use debounce instead of onBlur to update image fees info * Fix invoice amount * Refactor avatar upload control flow * Update image fees in onChange * Fix rescheduling of other jobs * also update schedule from every minute to every hour * Add image fees in calling context * keep item ids on uploads * Fix incompatible onSubmit signature * Revert "keep item ids on uploads" This reverts commit 4688962abcd54fdc5850109372a7ad054cf9b2e4. * many2many item uploads * pretty subdomain for images * handle upload conditions for profile images and job logos --------- Co-authored-by: ekzyis <ek@ekzyis.com> Co-authored-by: ekzyis <ek@stacker.news>
2023-11-06 20:53:33 +00:00
@@index([photoId])
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "users.created_at_index")
@@index([inviteId], map: "users.inviteId_index")
@@map("users")
2021-03-25 19:29:24 +00:00
}
2023-09-28 20:02:25 +00:00
model Mute {
muterId Int
mutedId Int
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
muter User @relation("muter", fields: [muterId], references: [id], onDelete: Cascade)
muted User @relation("muted", fields: [mutedId], references: [id], onDelete: Cascade)
@@id([muterId, mutedId])
@@index([mutedId, muterId])
}
2023-09-14 15:46:59 +00:00
model Arc {
fromId Int
fromUser User @relation("fromUser", fields: [fromId], references: [id], onDelete: Cascade)
toId Int
toUser User @relation("toUser", fields: [toId], references: [id], onDelete: Cascade)
zapTrust Float
@@id([fromId, toId])
@@index([toId, fromId])
}
2023-02-01 14:44:35 +00:00
model Streak {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2023-02-01 14:44:35 +00:00
startedAt DateTime @db.Date
endedAt DateTime? @db.Date
userId Int
2023-07-26 16:01:31 +00:00
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2023-02-01 14:44:35 +00:00
2023-07-26 16:01:31 +00:00
@@unique([startedAt, userId], map: "Streak.startedAt_userId_unique")
@@index([userId], map: "Streak.userId_index")
2023-02-01 14:44:35 +00:00
}
2023-01-07 00:53:09 +00:00
model NostrRelay {
addr String @id
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2023-01-07 00:53:09 +00:00
users UserNostrRelay[]
}
model UserNostrRelay {
userId Int
nostrRelayAddr String
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
NostrRelay NostrRelay @relation(fields: [nostrRelayAddr], references: [addr], onDelete: Cascade)
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
2023-01-07 00:53:09 +00:00
@@id([userId, nostrRelayAddr])
}
2022-12-08 00:04:02 +00:00
model Donation {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2022-12-08 00:04:02 +00:00
sats Int
userId Int
2023-07-26 16:01:31 +00:00
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-12-08 00:04:02 +00:00
}
Image uploads (#576) * Add icon to add images * Open file explorer to select image * Upload images to S3 on selection * Show uploaded images below text input * Link and remove image * Fetch unsubmitted images from database * Mark S3 images as submitted in imgproxy job * Add margin-top * Mark images as submitted on client after successful mutation * Also delete objects in S3 * Allow items to have multiple uploads linked * Overwrite old avatar * Add fees for presigned URLs * Use Github style upload * removed upfront fees * removed images provider since we no longer need to keep track of unsubmitted images on the client * removed User.images resolver * removed deleteImage mutation * use Github style upload where it shows ![Uploading <filename>...]() first and then replaces that with ![<filename>](<url>) after successful upload * Add Upload.paid boolean column One item can have multiple images linked to it, but an image can also be used in multiple items (many-to-many relation). Since we don't really care to which item an image is linked and vice versa, we just use a boolean column to mark if an image was already paid for. This makes fee calculation easier since no JOINs are required. * Add image fees during item creation/update * we calculate image fees during item creation and update now * function imageFees returns queries which deduct fees from user and mark images as paid + fees * queries need to be run inside same transaction as item creation/update * Allow anons to get presigned URLs * Add comments regarding avatar upload * Use megabytes in error message * Remove unnecessary avatar check during image fees calculation * Show image fees in frontend * Also update image fees on blur This makes sure that the images fees reflect the current state. For example, if an image was removed. We could also add debounced requests. * Show amount of unpaid images in receipt * Fix fees in sats deducted from msats * Fix algebraic order of fees Spam fees must come immediately after the base fee since it multiplies the base fee. * Fix image fees in edit receipt * Fix stale fees shown If we pay for an image and then want to edit the comment, the cache might return stale date; suggesting we didn't pay for the existing image yet. * Add 0 base fee in edit receipt * Remove 's' from 'image fees' in receipts * Remove unnecessary async * Remove 'Uploading <name>...' from text input on error * Support upload of multiple files at once * Add schedule to delete unused images * Fix image fee display in receipts * Use Drag and Drop API for image upload * Remove dragOver style on drop * Increase max upload size to 10MB to allow HQ camera pictures * Fix free upload quota * Fix stale image fees served * Fix bad image fee return statements * Fix multiplication with feesPerImage * Fix NULL returned for size24h, sizeNow * Remove unnecessary text field in query * refactor: Unify <ImageUpload> and <Upload> component * Add avatar cache busting using random query param * Calculate image fee info in postgres function * we now calculate image fee info in a postgres function which is much cleaner * we use this function inside `create_item` and `update_item`: image fees are now deducted in the same transaction as creating/updating the item! * reversed changes in `serializeInvoiceable` * Fix line break in receipt * Update upload limits * Add comment about `e.target.value = null` * Use debounce instead of onBlur to update image fees info * Fix invoice amount * Refactor avatar upload control flow * Update image fees in onChange * Fix rescheduling of other jobs * also update schedule from every minute to every hour * Add image fees in calling context * keep item ids on uploads * Fix incompatible onSubmit signature * Revert "keep item ids on uploads" This reverts commit 4688962abcd54fdc5850109372a7ad054cf9b2e4. * many2many item uploads * pretty subdomain for images * handle upload conditions for profile images and job logos --------- Co-authored-by: ekzyis <ek@ekzyis.com> Co-authored-by: ekzyis <ek@stacker.news>
2023-11-06 20:53:33 +00:00
model ItemUpload {
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
Image uploads (#576) * Add icon to add images * Open file explorer to select image * Upload images to S3 on selection * Show uploaded images below text input * Link and remove image * Fetch unsubmitted images from database * Mark S3 images as submitted in imgproxy job * Add margin-top * Mark images as submitted on client after successful mutation * Also delete objects in S3 * Allow items to have multiple uploads linked * Overwrite old avatar * Add fees for presigned URLs * Use Github style upload * removed upfront fees * removed images provider since we no longer need to keep track of unsubmitted images on the client * removed User.images resolver * removed deleteImage mutation * use Github style upload where it shows ![Uploading <filename>...]() first and then replaces that with ![<filename>](<url>) after successful upload * Add Upload.paid boolean column One item can have multiple images linked to it, but an image can also be used in multiple items (many-to-many relation). Since we don't really care to which item an image is linked and vice versa, we just use a boolean column to mark if an image was already paid for. This makes fee calculation easier since no JOINs are required. * Add image fees during item creation/update * we calculate image fees during item creation and update now * function imageFees returns queries which deduct fees from user and mark images as paid + fees * queries need to be run inside same transaction as item creation/update * Allow anons to get presigned URLs * Add comments regarding avatar upload * Use megabytes in error message * Remove unnecessary avatar check during image fees calculation * Show image fees in frontend * Also update image fees on blur This makes sure that the images fees reflect the current state. For example, if an image was removed. We could also add debounced requests. * Show amount of unpaid images in receipt * Fix fees in sats deducted from msats * Fix algebraic order of fees Spam fees must come immediately after the base fee since it multiplies the base fee. * Fix image fees in edit receipt * Fix stale fees shown If we pay for an image and then want to edit the comment, the cache might return stale date; suggesting we didn't pay for the existing image yet. * Add 0 base fee in edit receipt * Remove 's' from 'image fees' in receipts * Remove unnecessary async * Remove 'Uploading <name>...' from text input on error * Support upload of multiple files at once * Add schedule to delete unused images * Fix image fee display in receipts * Use Drag and Drop API for image upload * Remove dragOver style on drop * Increase max upload size to 10MB to allow HQ camera pictures * Fix free upload quota * Fix stale image fees served * Fix bad image fee return statements * Fix multiplication with feesPerImage * Fix NULL returned for size24h, sizeNow * Remove unnecessary text field in query * refactor: Unify <ImageUpload> and <Upload> component * Add avatar cache busting using random query param * Calculate image fee info in postgres function * we now calculate image fee info in a postgres function which is much cleaner * we use this function inside `create_item` and `update_item`: image fees are now deducted in the same transaction as creating/updating the item! * reversed changes in `serializeInvoiceable` * Fix line break in receipt * Update upload limits * Add comment about `e.target.value = null` * Use debounce instead of onBlur to update image fees info * Fix invoice amount * Refactor avatar upload control flow * Update image fees in onChange * Fix rescheduling of other jobs * also update schedule from every minute to every hour * Add image fees in calling context * keep item ids on uploads * Fix incompatible onSubmit signature * Revert "keep item ids on uploads" This reverts commit 4688962abcd54fdc5850109372a7ad054cf9b2e4. * many2many item uploads * pretty subdomain for images * handle upload conditions for profile images and job logos --------- Co-authored-by: ekzyis <ek@ekzyis.com> Co-authored-by: ekzyis <ek@stacker.news>
2023-11-06 20:53:33 +00:00
itemId Int
uploadId Int
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
upload Upload @relation(fields: [uploadId], references: [id], onDelete: Cascade)
@@id([itemId, uploadId])
@@index([createdAt])
@@index([itemId])
@@index([uploadId])
}
model Upload {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
type String
size Int
width Int?
height Int?
userId Int
paid Boolean?
user User @relation("Uploads", fields: [userId], references: [id], onDelete: Cascade)
User User[]
ItemUpload ItemUpload[]
2022-05-12 18:44:21 +00:00
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "Upload.created_at_index")
@@index([userId], map: "Upload.userId_index")
}
2022-03-17 20:13:19 +00:00
model Earn {
2023-07-26 16:01:31 +00:00
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
msats BigInt
userId Int
rank Int?
type EarnType?
typeId Int?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "Earn.created_at_index")
@@index([createdAt, userId], map: "Earn.created_at_userId_index")
@@index([userId], map: "Earn.userId_index")
2022-03-17 20:13:19 +00:00
}
2021-06-27 03:09:39 +00:00
model LnAuth {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
k1 String @unique(map: "LnAuth.k1_unique")
2021-06-27 03:09:39 +00:00
pubkey String?
}
2021-10-28 19:59:53 +00:00
model LnWith {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
k1 String @unique(map: "LnWith.k1_unique")
2021-10-28 19:59:53 +00:00
userId Int
withdrawalId Int?
}
2021-10-12 20:40:30 +00:00
model Invite {
id String @id @default(cuid())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2021-10-12 20:40:30 +00:00
userId Int
gift Int?
limit Int?
revoked Boolean @default(false)
2023-07-26 16:01:31 +00:00
user User @relation("Invites", fields: [userId], references: [id], onDelete: Cascade)
2021-10-12 20:40:30 +00:00
invitees User[]
2022-03-10 19:26:35 +00:00
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "Invite.created_at_index")
@@index([userId], map: "Invite.userId_index")
2021-10-12 20:40:30 +00:00
}
2021-03-25 19:29:24 +00:00
model Message {
id Int @id @default(autoincrement())
text String
userId Int
2023-07-26 16:01:31 +00:00
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-02-25 17:34:09 +00:00
}
2023-07-27 00:18:42 +00:00
/// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info.
2021-03-25 19:29:24 +00:00
model Item {
2023-07-26 16:01:31 +00:00
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
title String?
text String?
url String?
userId Int
parentId Int?
path Unsupported("ltree")?
pinId Int?
latitude Float?
location String?
longitude Float?
maxBid Int?
maxSalary Int?
minSalary Int?
remote Boolean?
subName String? @db.Citext
statusUpdatedAt DateTime?
status Status @default(ACTIVE)
company String?
weightedVotes Float @default(0)
boost Int @default(0)
pollCost Int?
paidImgLink Boolean @default(false)
commentMsats BigInt @default(0)
lastCommentAt DateTime?
ncomments Int @default(0)
msats BigInt @default(0)
weightedDownVotes Float @default(0)
bio Boolean @default(false)
freebie Boolean @default(false)
deletedAt DateTime?
otsFile Bytes?
otsHash String?
2023-10-01 23:03:52 +00:00
imgproxyUrls Json?
2023-07-26 16:01:31 +00:00
bounty Int?
noteId String? @unique(map: "Item.noteId_unique")
2023-07-26 16:01:31 +00:00
rootId Int?
bountyPaidTo Int[]
upvotes Int @default(0)
weightedComments Float @default(0)
2023-07-27 00:18:42 +00:00
Bookmark Bookmark[]
2023-07-26 16:01:31 +00:00
parent Item? @relation("ParentChildren", fields: [parentId], references: [id])
2023-07-27 00:18:42 +00:00
children Item[] @relation("ParentChildren")
2023-07-26 16:01:31 +00:00
pin Pin? @relation(fields: [pinId], references: [id])
root Item? @relation("RootDescendant", fields: [rootId], references: [id])
2023-07-27 00:18:42 +00:00
descendants Item[] @relation("RootDescendant")
2023-07-26 16:01:31 +00:00
sub Sub? @relation(fields: [subName], references: [name])
user User @relation("UserItems", fields: [userId], references: [id], onDelete: Cascade)
actions ItemAct[]
mentions Mention[]
2023-06-20 01:26:34 +00:00
PollOption PollOption[]
PollVote PollVote[]
ThreadSubscription ThreadSubscription[]
2023-07-26 16:01:31 +00:00
User User[]
multiple forwards on a post (#403) * multiple forwards on a post first phase of the multi-forward support * update the graphql mutation for discussion posts to accept and validate multiple forwards * update the discussion form to allow multiple forwards in the UI * start working on db schema changes * uncomment db schema, add migration to create the new model, and update create_item, update_item stored procedures * Propagate updates from discussion to poll, link, and bounty forms Update the create, update poll sql functions for multi forward support * Update gql, typedefs, and resolver to return forwarded users in items responses * UI changes to show multiple forward recipients, and conditional upvote logic changes * Update notification text to reflect multiple forwards upon vote action * Disallow duplicate stacker entries * reduce duplication in populating adv-post-form initial values * Update item_act sql function to implement multi-way forwarding * Update referral functions to scale referral bonuses for forwarded users * Update notification text to reflect non-100% forwarded sats cases * Update wallet history sql queries to accommodate multi-forward use cases * Block zaps for posts you are forwarded zaps at the API layer, in addition to in the UI * Delete fwdUserId column from Item table as part of migration * Fix how we calculate stacked sats after partial forwards in wallet history * Exclude entries from wallet history that are 0 stacked sats from posts with 100% forwarded to other users * Fix wallet history query for forwarded stacked sats to be scaled by the fwd pct * Reduce duplication in adv post form, and do some style tweaks for better layout * Use MAX_FORWARDS constants * Address various PR feedback * first enhancement pass * enhancement pass too --------- Co-authored-by: keyan <keyan.kousha+huumn@gmail.com> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-08-23 22:44:17 +00:00
itemForwards ItemForward[]
Image uploads (#576) * Add icon to add images * Open file explorer to select image * Upload images to S3 on selection * Show uploaded images below text input * Link and remove image * Fetch unsubmitted images from database * Mark S3 images as submitted in imgproxy job * Add margin-top * Mark images as submitted on client after successful mutation * Also delete objects in S3 * Allow items to have multiple uploads linked * Overwrite old avatar * Add fees for presigned URLs * Use Github style upload * removed upfront fees * removed images provider since we no longer need to keep track of unsubmitted images on the client * removed User.images resolver * removed deleteImage mutation * use Github style upload where it shows ![Uploading <filename>...]() first and then replaces that with ![<filename>](<url>) after successful upload * Add Upload.paid boolean column One item can have multiple images linked to it, but an image can also be used in multiple items (many-to-many relation). Since we don't really care to which item an image is linked and vice versa, we just use a boolean column to mark if an image was already paid for. This makes fee calculation easier since no JOINs are required. * Add image fees during item creation/update * we calculate image fees during item creation and update now * function imageFees returns queries which deduct fees from user and mark images as paid + fees * queries need to be run inside same transaction as item creation/update * Allow anons to get presigned URLs * Add comments regarding avatar upload * Use megabytes in error message * Remove unnecessary avatar check during image fees calculation * Show image fees in frontend * Also update image fees on blur This makes sure that the images fees reflect the current state. For example, if an image was removed. We could also add debounced requests. * Show amount of unpaid images in receipt * Fix fees in sats deducted from msats * Fix algebraic order of fees Spam fees must come immediately after the base fee since it multiplies the base fee. * Fix image fees in edit receipt * Fix stale fees shown If we pay for an image and then want to edit the comment, the cache might return stale date; suggesting we didn't pay for the existing image yet. * Add 0 base fee in edit receipt * Remove 's' from 'image fees' in receipts * Remove unnecessary async * Remove 'Uploading <name>...' from text input on error * Support upload of multiple files at once * Add schedule to delete unused images * Fix image fee display in receipts * Use Drag and Drop API for image upload * Remove dragOver style on drop * Increase max upload size to 10MB to allow HQ camera pictures * Fix free upload quota * Fix stale image fees served * Fix bad image fee return statements * Fix multiplication with feesPerImage * Fix NULL returned for size24h, sizeNow * Remove unnecessary text field in query * refactor: Unify <ImageUpload> and <Upload> component * Add avatar cache busting using random query param * Calculate image fee info in postgres function * we now calculate image fee info in a postgres function which is much cleaner * we use this function inside `create_item` and `update_item`: image fees are now deducted in the same transaction as creating/updating the item! * reversed changes in `serializeInvoiceable` * Fix line break in receipt * Update upload limits * Add comment about `e.target.value = null` * Use debounce instead of onBlur to update image fees info * Fix invoice amount * Refactor avatar upload control flow * Update image fees in onChange * Fix rescheduling of other jobs * also update schedule from every minute to every hour * Add image fees in calling context * keep item ids on uploads * Fix incompatible onSubmit signature * Revert "keep item ids on uploads" This reverts commit 4688962abcd54fdc5850109372a7ad054cf9b2e4. * many2many item uploads * pretty subdomain for images * handle upload conditions for profile images and job logos --------- Co-authored-by: ekzyis <ek@ekzyis.com> Co-authored-by: ekzyis <ek@stacker.news>
2023-11-06 20:53:33 +00:00
ItemUpload ItemUpload[]
uploadId Int?
outlawed Boolean @default(false)
2022-08-06 22:03:57 +00:00
Image uploads (#576) * Add icon to add images * Open file explorer to select image * Upload images to S3 on selection * Show uploaded images below text input * Link and remove image * Fetch unsubmitted images from database * Mark S3 images as submitted in imgproxy job * Add margin-top * Mark images as submitted on client after successful mutation * Also delete objects in S3 * Allow items to have multiple uploads linked * Overwrite old avatar * Add fees for presigned URLs * Use Github style upload * removed upfront fees * removed images provider since we no longer need to keep track of unsubmitted images on the client * removed User.images resolver * removed deleteImage mutation * use Github style upload where it shows ![Uploading <filename>...]() first and then replaces that with ![<filename>](<url>) after successful upload * Add Upload.paid boolean column One item can have multiple images linked to it, but an image can also be used in multiple items (many-to-many relation). Since we don't really care to which item an image is linked and vice versa, we just use a boolean column to mark if an image was already paid for. This makes fee calculation easier since no JOINs are required. * Add image fees during item creation/update * we calculate image fees during item creation and update now * function imageFees returns queries which deduct fees from user and mark images as paid + fees * queries need to be run inside same transaction as item creation/update * Allow anons to get presigned URLs * Add comments regarding avatar upload * Use megabytes in error message * Remove unnecessary avatar check during image fees calculation * Show image fees in frontend * Also update image fees on blur This makes sure that the images fees reflect the current state. For example, if an image was removed. We could also add debounced requests. * Show amount of unpaid images in receipt * Fix fees in sats deducted from msats * Fix algebraic order of fees Spam fees must come immediately after the base fee since it multiplies the base fee. * Fix image fees in edit receipt * Fix stale fees shown If we pay for an image and then want to edit the comment, the cache might return stale date; suggesting we didn't pay for the existing image yet. * Add 0 base fee in edit receipt * Remove 's' from 'image fees' in receipts * Remove unnecessary async * Remove 'Uploading <name>...' from text input on error * Support upload of multiple files at once * Add schedule to delete unused images * Fix image fee display in receipts * Use Drag and Drop API for image upload * Remove dragOver style on drop * Increase max upload size to 10MB to allow HQ camera pictures * Fix free upload quota * Fix stale image fees served * Fix bad image fee return statements * Fix multiplication with feesPerImage * Fix NULL returned for size24h, sizeNow * Remove unnecessary text field in query * refactor: Unify <ImageUpload> and <Upload> component * Add avatar cache busting using random query param * Calculate image fee info in postgres function * we now calculate image fee info in a postgres function which is much cleaner * we use this function inside `create_item` and `update_item`: image fees are now deducted in the same transaction as creating/updating the item! * reversed changes in `serializeInvoiceable` * Fix line break in receipt * Update upload limits * Add comment about `e.target.value = null` * Use debounce instead of onBlur to update image fees info * Fix invoice amount * Refactor avatar upload control flow * Update image fees in onChange * Fix rescheduling of other jobs * also update schedule from every minute to every hour * Add image fees in calling context * keep item ids on uploads * Fix incompatible onSubmit signature * Revert "keep item ids on uploads" This reverts commit 4688962abcd54fdc5850109372a7ad054cf9b2e4. * many2many item uploads * pretty subdomain for images * handle upload conditions for profile images and job logos --------- Co-authored-by: ekzyis <ek@ekzyis.com> Co-authored-by: ekzyis <ek@stacker.news>
2023-11-06 20:53:33 +00:00
@@index([uploadId])
2023-07-26 16:01:31 +00:00
@@index([bio], map: "Item.bio_index")
@@index([createdAt], map: "Item.created_at_index")
@@index([freebie], map: "Item.freebie_index")
@@index([maxBid], map: "Item.maxBid_index")
@@index([parentId], map: "Item.parentId_index")
2023-07-27 00:18:42 +00:00
@@index([path], map: "Item.path_index", type: Gist)
@@index([path], map: "Item.path_index0", type: Gist)
2023-07-26 16:01:31 +00:00
@@index([pinId], map: "Item.pinId_index")
@@index([rootId], map: "Item.rootId_index")
@@index([statusUpdatedAt], map: "Item.statusUpdatedAt_index")
@@index([status], map: "Item.status_index")
@@index([subName], map: "Item.subName_index")
@@index([userId], map: "Item.userId_index")
@@index([weightedDownVotes], map: "Item.weightedDownVotes_index")
@@index([weightedVotes], map: "Item.weightedVotes_index")
2021-03-25 19:29:24 +00:00
}
multiple forwards on a post (#403) * multiple forwards on a post first phase of the multi-forward support * update the graphql mutation for discussion posts to accept and validate multiple forwards * update the discussion form to allow multiple forwards in the UI * start working on db schema changes * uncomment db schema, add migration to create the new model, and update create_item, update_item stored procedures * Propagate updates from discussion to poll, link, and bounty forms Update the create, update poll sql functions for multi forward support * Update gql, typedefs, and resolver to return forwarded users in items responses * UI changes to show multiple forward recipients, and conditional upvote logic changes * Update notification text to reflect multiple forwards upon vote action * Disallow duplicate stacker entries * reduce duplication in populating adv-post-form initial values * Update item_act sql function to implement multi-way forwarding * Update referral functions to scale referral bonuses for forwarded users * Update notification text to reflect non-100% forwarded sats cases * Update wallet history sql queries to accommodate multi-forward use cases * Block zaps for posts you are forwarded zaps at the API layer, in addition to in the UI * Delete fwdUserId column from Item table as part of migration * Fix how we calculate stacked sats after partial forwards in wallet history * Exclude entries from wallet history that are 0 stacked sats from posts with 100% forwarded to other users * Fix wallet history query for forwarded stacked sats to be scaled by the fwd pct * Reduce duplication in adv post form, and do some style tweaks for better layout * Use MAX_FORWARDS constants * Address various PR feedback * first enhancement pass * enhancement pass too --------- Co-authored-by: keyan <keyan.kousha+huumn@gmail.com> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-08-23 22:44:17 +00:00
// TODO: make all Item's forward 100% of sats to the OP by default
// so that forwards aren't a special case everywhere
model ItemForward {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
itemId Int // The item from which sats are forwarded
userId Int // The recipient of the forwarded sats
pct Int // The percentage of sats from the item to forward to this user
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([itemId], map: "ItemForward.itemId_index")
@@index([userId], map: "ItemForward.userId_index")
@@index([createdAt], map: "ItemForward.createdAt_index")
}
2022-07-30 13:25:46 +00:00
model PollOption {
2023-07-26 16:01:31 +00:00
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2022-07-30 13:25:46 +00:00
itemId Int
option String
2023-07-26 16:01:31 +00:00
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
PollVote PollVote[]
2022-07-30 13:25:46 +00:00
2023-07-26 16:01:31 +00:00
@@index([itemId], map: "PollOption.itemId_index")
2022-07-30 13:25:46 +00:00
}
model PollVote {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2022-07-30 13:25:46 +00:00
userId Int
itemId Int
pollOptionId Int
2023-07-26 16:01:31 +00:00
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
pollOption PollOption @relation(fields: [pollOptionId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-07-30 13:25:46 +00:00
2023-07-26 16:01:31 +00:00
@@unique([itemId, userId], map: "PollVote.itemId_userId_unique")
@@index([pollOptionId], map: "PollVote.pollOptionId_index")
@@index([userId], map: "PollVote.userId_index")
2022-02-17 17:23:43 +00:00
}
2023-11-21 23:32:22 +00:00
enum BillingType {
MONTHLY
YEARLY
ONCE
}
enum RankingType {
WOT
RECENT
AUCTION
}
2022-02-17 17:23:43 +00:00
model Sub {
2023-11-21 23:32:22 +00:00
name String @id @db.Citext
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId Int
parentName String? @db.Citext
path Unsupported("ltree")?
2023-12-08 20:02:00 +00:00
postTypes PostType[]
rankingType RankingType
allowFreebies Boolean @default(true)
2023-12-08 20:02:00 +00:00
baseCost Int @default(1)
rewardsPct Int @default(50)
desc String?
status Status @default(ACTIVE)
billingType BillingType
billingCost Int
billingAutoRenew Boolean @default(false)
billedLastAt DateTime @default(now())
moderated Boolean @default(false)
moderatedCount Int @default(0)
2023-11-21 23:32:22 +00:00
parent Sub? @relation("ParentChildren", fields: [parentName], references: [name])
children Sub[] @relation("ParentChildren")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2023-05-01 20:58:30 +00:00
Item Item[]
Subscription Subscription[]
2023-11-21 23:32:22 +00:00
SubAct SubAct[]
@@index([parentName])
@@index([createdAt])
@@index([userId])
@@index([path], type: Gist)
}
model SubAct {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId Int
subName String @db.Citext
msats BigInt
type SubActType
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
sub Sub @relation(fields: [subName], references: [name], onDelete: Cascade)
@@index([userId])
@@index([userId, type])
@@index([type])
@@index([createdAt])
@@index([createdAt, type])
@@index([userId, createdAt, type])
2023-05-01 20:58:30 +00:00
}
model Subscription {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2023-05-01 20:58:30 +00:00
subName String @db.Citext
userId Int
2023-07-26 16:01:31 +00:00
sub Sub @relation(fields: [subName], references: [name], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-02-17 17:23:43 +00:00
}
2022-01-07 16:32:31 +00:00
model Pin {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2022-01-07 16:32:31 +00:00
cron String?
timezone String?
position Int
Item Item[]
}
2022-12-19 22:27:52 +00:00
model ReferralAct {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2022-12-19 22:27:52 +00:00
referrerId Int
itemActId Int
msats BigInt
2023-07-26 16:01:31 +00:00
itemAct ItemAct @relation(fields: [itemActId], references: [id], onDelete: Cascade)
referrer User @relation(fields: [referrerId], references: [id], onDelete: Cascade)
2023-08-10 02:27:53 +00:00
@@index([referrerId])
@@index([itemActId])
2021-09-08 21:15:06 +00:00
}
2021-09-08 21:51:23 +00:00
model ItemAct {
2023-07-26 16:01:31 +00:00
id Int @id(map: "Vote_pkey") @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
2023-08-24 00:06:26 +00:00
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2022-12-19 22:27:52 +00:00
msats BigInt
act ItemActType
itemId Int
userId Int
2023-07-26 16:01:31 +00:00
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-12-19 22:27:52 +00:00
ReferralAct ReferralAct[]
2021-04-22 22:14:32 +00:00
2023-07-26 16:01:31 +00:00
@@index([act], map: "ItemAct.act_index")
@@index([createdAt], map: "ItemAct.created_at_index")
@@index([createdAt, itemId, act], map: "ItemAct.created_at_itemId_act_index")
@@index([itemId, createdAt, act], map: "ItemAct.itemId_created_at_act_index")
@@index([itemId], map: "ItemAct.itemId_index")
@@index([itemId, userId, act], map: "ItemAct.itemId_userId_act_index")
@@index([userId, createdAt, act], map: "ItemAct.userId_created_at_act_index")
@@index([userId], map: "ItemAct.userId_index")
@@index([itemId], map: "Vote.itemId_index")
@@index([userId], map: "Vote.userId_index")
2021-04-22 22:14:32 +00:00
}
2021-08-18 22:20:33 +00:00
model Mention {
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
2023-08-24 00:06:26 +00:00
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2021-08-18 22:20:33 +00:00
itemId Int
userId Int
2023-07-26 16:01:31 +00:00
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2021-08-18 22:20:33 +00:00
2023-07-26 16:01:31 +00:00
@@unique([itemId, userId], map: "Mention.itemId_userId_unique")
@@index([createdAt], map: "Mention.created_at_index")
@@index([itemId], map: "Mention.itemId_index")
@@index([userId], map: "Mention.userId_index")
2021-08-18 22:20:33 +00:00
}
2021-05-11 15:52:50 +00:00
model Invoice {
2023-07-26 16:01:31 +00:00
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
2023-08-24 00:06:26 +00:00
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2023-07-26 16:01:31 +00:00
userId Int
hash String @unique(map: "Invoice.hash_unique")
preimage String? @unique(map: "Invoice.preimage_unique")
isHeld Boolean?
2021-05-11 15:52:50 +00:00
bolt11 String
expiresAt DateTime
confirmedAt DateTime?
2023-07-26 16:01:31 +00:00
cancelled Boolean @default(false)
2022-11-15 20:51:55 +00:00
msatsRequested BigInt
msatsReceived BigInt?
2023-07-26 16:01:31 +00:00
desc String?
comment String?
lud18Data Json?
2023-07-26 16:01:31 +00:00
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2021-05-11 15:52:50 +00:00
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "Invoice.created_at_index")
@@index([userId], map: "Invoice.userId_index")
2021-05-12 23:04:19 +00:00
}
model Withdrawl {
2023-07-26 16:01:31 +00:00
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
2023-08-24 00:06:26 +00:00
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2023-07-26 16:01:31 +00:00
userId Int
hash String?
bolt11 String?
2022-11-15 20:51:55 +00:00
msatsPaying BigInt
msatsPaid BigInt?
msatsFeePaying BigInt
msatsFeePaid BigInt?
2023-07-26 16:01:31 +00:00
status WithdrawlStatus?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2021-05-12 23:04:19 +00:00
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "Withdrawl.created_at_index")
@@index([userId], map: "Withdrawl.userId_index")
2021-05-12 23:04:19 +00:00
}
2021-03-25 19:29:24 +00:00
model Account {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
2023-08-24 00:06:26 +00:00
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId Int @map("user_id")
type String @map("provider_type")
provider String @map("provider_id")
providerAccountId String @map("provider_account_id")
refresh_token String? @map("refresh_token")
access_token String? @map("access_token")
expires_at String? @map("access_token_expires")
token_type String?
scope String?
id_token String?
session_state String?
2023-08-07 20:05:55 +00:00
// twitter oauth 1.0 needs these https://authjs.dev/reference/core/providers_twitter#notes
oauth_token String?
oauth_token_secret String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
2023-07-26 16:01:31 +00:00
@@index([userId], map: "accounts.user_id_index")
@@map("accounts")
2021-03-25 19:29:24 +00:00
}
2023-12-14 17:30:51 +00:00
model OFAC {
id Int @id @default(autoincrement())
startIP Unsupported("ipaddress")
endIP Unsupported("ipaddress")
country String
countryCode String
}
2021-03-25 19:29:24 +00:00
model Session {
id Int @id @default(autoincrement())
sessionToken String @unique(map: "sessions.session_token_unique") @map("session_token")
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
2023-08-24 00:06:26 +00:00
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2023-07-26 16:01:31 +00:00
userId Int @map("user_id")
2021-03-25 19:29:24 +00:00
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2021-03-25 19:29:24 +00:00
2023-07-26 16:01:31 +00:00
@@map("sessions")
2021-03-25 19:29:24 +00:00
}
model VerificationToken {
2021-03-25 19:29:24 +00:00
id Int @id @default(autoincrement())
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
2023-08-24 00:06:26 +00:00
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
2021-03-25 19:29:24 +00:00
identifier String
2023-07-26 16:01:31 +00:00
token String @unique(map: "verification_requests.token_unique")
2021-03-25 19:29:24 +00:00
expires DateTime
@@unique([identifier, token])
2023-07-26 16:01:31 +00:00
@@map("verification_requests")
2021-03-25 19:29:24 +00:00
}
model Bookmark {
userId Int
itemId Int
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2023-02-24 16:35:05 +00:00
@@id([userId, itemId])
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "Bookmark.created_at_index")
}
multiple forwards on a post (#403) * multiple forwards on a post first phase of the multi-forward support * update the graphql mutation for discussion posts to accept and validate multiple forwards * update the discussion form to allow multiple forwards in the UI * start working on db schema changes * uncomment db schema, add migration to create the new model, and update create_item, update_item stored procedures * Propagate updates from discussion to poll, link, and bounty forms Update the create, update poll sql functions for multi forward support * Update gql, typedefs, and resolver to return forwarded users in items responses * UI changes to show multiple forward recipients, and conditional upvote logic changes * Update notification text to reflect multiple forwards upon vote action * Disallow duplicate stacker entries * reduce duplication in populating adv-post-form initial values * Update item_act sql function to implement multi-way forwarding * Update referral functions to scale referral bonuses for forwarded users * Update notification text to reflect non-100% forwarded sats cases * Update wallet history sql queries to accommodate multi-forward use cases * Block zaps for posts you are forwarded zaps at the API layer, in addition to in the UI * Delete fwdUserId column from Item table as part of migration * Fix how we calculate stacked sats after partial forwards in wallet history * Exclude entries from wallet history that are 0 stacked sats from posts with 100% forwarded to other users * Fix wallet history query for forwarded stacked sats to be scaled by the fwd pct * Reduce duplication in adv post form, and do some style tweaks for better layout * Use MAX_FORWARDS constants * Address various PR feedback * first enhancement pass * enhancement pass too --------- Co-authored-by: keyan <keyan.kousha+huumn@gmail.com> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-08-23 22:44:17 +00:00
// TODO: make thread subscriptions for OP by default so they can
// unsubscribe from their own threads and its not a special case
model ThreadSubscription {
userId Int
itemId Int
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([userId, itemId])
2023-07-26 16:01:31 +00:00
@@index([createdAt], map: "ThreadSubscription.created_at_index")
2023-06-20 01:26:34 +00:00
}
Service worker rework, Web Target Share API & Web Push API (#324) * npm uninstall next-pwa next-pwa was last updated in August 2022. There is also an issue which mentions that next-pwa is abandoned (?): https://github.com/shadowwalker/next-pwa/issues/482 But the main reason for me uninstalling it is that it adds a lot of preconfigured stuff which is not necessary for us. It even lead to a bug since pages were cached without our knowledge. So I will go with a different PWA approach. This different approach should do the following: - make it more transparent what the service worker is doing - gives us more control to configure the service worker and thus making it easier * Use workbox-webpack-plugin Every other plugin (`next-offline`, `next-workbox-webpack-plugin`, `next-with-workbox`, ...) added unnecessary configuration which felt contrary to how PWAs should be built. (PWAs should progressivly enhance the website in small steps, see https://web.dev/learn/pwa/getting-started/#focus-on-a-feature) These default configurations even lead to worse UX since they made invalid assumptions about stacker.news: We _do not_ want to cache our start url and we _do not_ want to cache anything unless explicitly told to. Almost every page on SN should be fresh for the best UX. To achieve this, by default, the service worker falls back to the network (as if the service worker wasn't there). Therefore, this should be the simplest configuration with a valid precache and cache busting support. In the future, we can try to use prefetching to improve performance of navigation requests. * Add support for Web Share Target API See https://developer.chrome.com/articles/web-share-target/ * Use Web Push API for push notifications I followed this (very good!) guide: https://web.dev/notifications/ * Refactor code related to Web Push * Send push notification to users on events * Merge notifications * Send notification to author of every parent recursively * Remove unused userId param in savePushSubscription As it should be, the user id is retrieved from the authenticated user in the backend. * Resubscribe user if push subscription changed * Update old subscription if oldEndpoint was given * Allow users to unsubscribe * Use LTREE operator instead of recursive query * Always show checkbox for push notifications * Justify checkbox to end * Update title of first push notification * Fix warning from uncontrolled to controlled * Add comment about Notification.requestPermission * Fix timestamp * Catch error on push subscription toggle * Wrap function bodies in try/catch * Use Promise.allSettled * Filter subscriptions by user notification settings * Fix user notification filter * Use skipWaiting --------- Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 19:36:07 +00:00
model UserSubscription {
2023-09-28 20:02:25 +00:00
followerId Int
followeeId Int
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
postsSubscribedAt DateTime?
commentsSubscribedAt DateTime?
follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade)
followee User @relation("followee", fields: [followeeId], references: [id], onDelete: Cascade)
@@id([followerId, followeeId])
@@index([createdAt], map: "UserSubscription.created_at_index")
@@index([followerId], map: "UserSubscription.follower_index")
@@index([followeeId], map: "UserSubscription.followee_index")
}
Service worker rework, Web Target Share API & Web Push API (#324) * npm uninstall next-pwa next-pwa was last updated in August 2022. There is also an issue which mentions that next-pwa is abandoned (?): https://github.com/shadowwalker/next-pwa/issues/482 But the main reason for me uninstalling it is that it adds a lot of preconfigured stuff which is not necessary for us. It even lead to a bug since pages were cached without our knowledge. So I will go with a different PWA approach. This different approach should do the following: - make it more transparent what the service worker is doing - gives us more control to configure the service worker and thus making it easier * Use workbox-webpack-plugin Every other plugin (`next-offline`, `next-workbox-webpack-plugin`, `next-with-workbox`, ...) added unnecessary configuration which felt contrary to how PWAs should be built. (PWAs should progressivly enhance the website in small steps, see https://web.dev/learn/pwa/getting-started/#focus-on-a-feature) These default configurations even lead to worse UX since they made invalid assumptions about stacker.news: We _do not_ want to cache our start url and we _do not_ want to cache anything unless explicitly told to. Almost every page on SN should be fresh for the best UX. To achieve this, by default, the service worker falls back to the network (as if the service worker wasn't there). Therefore, this should be the simplest configuration with a valid precache and cache busting support. In the future, we can try to use prefetching to improve performance of navigation requests. * Add support for Web Share Target API See https://developer.chrome.com/articles/web-share-target/ * Use Web Push API for push notifications I followed this (very good!) guide: https://web.dev/notifications/ * Refactor code related to Web Push * Send push notification to users on events * Merge notifications * Send notification to author of every parent recursively * Remove unused userId param in savePushSubscription As it should be, the user id is retrieved from the authenticated user in the backend. * Resubscribe user if push subscription changed * Update old subscription if oldEndpoint was given * Allow users to unsubscribe * Use LTREE operator instead of recursive query * Always show checkbox for push notifications * Justify checkbox to end * Update title of first push notification * Fix warning from uncontrolled to controlled * Add comment about Notification.requestPermission * Fix timestamp * Catch error on push subscription toggle * Wrap function bodies in try/catch * Use Promise.allSettled * Filter subscriptions by user notification settings * Fix user notification filter * Use skipWaiting --------- Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 19:36:07 +00:00
model PushSubscription {
2023-07-26 16:01:31 +00:00
id Int @id @default(autoincrement())
Service worker rework, Web Target Share API & Web Push API (#324) * npm uninstall next-pwa next-pwa was last updated in August 2022. There is also an issue which mentions that next-pwa is abandoned (?): https://github.com/shadowwalker/next-pwa/issues/482 But the main reason for me uninstalling it is that it adds a lot of preconfigured stuff which is not necessary for us. It even lead to a bug since pages were cached without our knowledge. So I will go with a different PWA approach. This different approach should do the following: - make it more transparent what the service worker is doing - gives us more control to configure the service worker and thus making it easier * Use workbox-webpack-plugin Every other plugin (`next-offline`, `next-workbox-webpack-plugin`, `next-with-workbox`, ...) added unnecessary configuration which felt contrary to how PWAs should be built. (PWAs should progressivly enhance the website in small steps, see https://web.dev/learn/pwa/getting-started/#focus-on-a-feature) These default configurations even lead to worse UX since they made invalid assumptions about stacker.news: We _do not_ want to cache our start url and we _do not_ want to cache anything unless explicitly told to. Almost every page on SN should be fresh for the best UX. To achieve this, by default, the service worker falls back to the network (as if the service worker wasn't there). Therefore, this should be the simplest configuration with a valid precache and cache busting support. In the future, we can try to use prefetching to improve performance of navigation requests. * Add support for Web Share Target API See https://developer.chrome.com/articles/web-share-target/ * Use Web Push API for push notifications I followed this (very good!) guide: https://web.dev/notifications/ * Refactor code related to Web Push * Send push notification to users on events * Merge notifications * Send notification to author of every parent recursively * Remove unused userId param in savePushSubscription As it should be, the user id is retrieved from the authenticated user in the backend. * Resubscribe user if push subscription changed * Update old subscription if oldEndpoint was given * Allow users to unsubscribe * Use LTREE operator instead of recursive query * Always show checkbox for push notifications * Justify checkbox to end * Update title of first push notification * Fix warning from uncontrolled to controlled * Add comment about Notification.requestPermission * Fix timestamp * Catch error on push subscription toggle * Wrap function bodies in try/catch * Use Promise.allSettled * Filter subscriptions by user notification settings * Fix user notification filter * Use skipWaiting --------- Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 19:36:07 +00:00
userId Int
endpoint String
p256dh String
auth String
2023-07-26 16:01:31 +00:00
createdAt DateTime @default(now()) @map("created_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Service worker rework, Web Target Share API & Web Push API (#324) * npm uninstall next-pwa next-pwa was last updated in August 2022. There is also an issue which mentions that next-pwa is abandoned (?): https://github.com/shadowwalker/next-pwa/issues/482 But the main reason for me uninstalling it is that it adds a lot of preconfigured stuff which is not necessary for us. It even lead to a bug since pages were cached without our knowledge. So I will go with a different PWA approach. This different approach should do the following: - make it more transparent what the service worker is doing - gives us more control to configure the service worker and thus making it easier * Use workbox-webpack-plugin Every other plugin (`next-offline`, `next-workbox-webpack-plugin`, `next-with-workbox`, ...) added unnecessary configuration which felt contrary to how PWAs should be built. (PWAs should progressivly enhance the website in small steps, see https://web.dev/learn/pwa/getting-started/#focus-on-a-feature) These default configurations even lead to worse UX since they made invalid assumptions about stacker.news: We _do not_ want to cache our start url and we _do not_ want to cache anything unless explicitly told to. Almost every page on SN should be fresh for the best UX. To achieve this, by default, the service worker falls back to the network (as if the service worker wasn't there). Therefore, this should be the simplest configuration with a valid precache and cache busting support. In the future, we can try to use prefetching to improve performance of navigation requests. * Add support for Web Share Target API See https://developer.chrome.com/articles/web-share-target/ * Use Web Push API for push notifications I followed this (very good!) guide: https://web.dev/notifications/ * Refactor code related to Web Push * Send push notification to users on events * Merge notifications * Send notification to author of every parent recursively * Remove unused userId param in savePushSubscription As it should be, the user id is retrieved from the authenticated user in the backend. * Resubscribe user if push subscription changed * Update old subscription if oldEndpoint was given * Allow users to unsubscribe * Use LTREE operator instead of recursive query * Always show checkbox for push notifications * Justify checkbox to end * Update title of first push notification * Fix warning from uncontrolled to controlled * Add comment about Notification.requestPermission * Fix timestamp * Catch error on push subscription toggle * Wrap function bodies in try/catch * Use Promise.allSettled * Filter subscriptions by user notification settings * Fix user notification filter * Use skipWaiting --------- Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 19:36:07 +00:00
2023-07-26 16:01:31 +00:00
@@index([userId], map: "PushSubscription.userId_index")
}
model Log {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
level LogLevel
name String
message String
env Json?
context Json?
@@index([createdAt, name], map: "Log.name_index")
}
2023-07-26 16:01:31 +00:00
enum EarnType {
POST
COMMENT
TIP_COMMENT
TIP_POST
}
2023-11-21 23:32:22 +00:00
enum SubActType {
BILLING
REVENUE
}
2023-07-26 16:01:31 +00:00
enum Status {
ACTIVE
STOPPED
NOSATS
2023-11-21 23:32:22 +00:00
GRACE
2023-07-26 16:01:31 +00:00
}
enum PostType {
LINK
DISCUSSION
JOB
POLL
BOUNTY
}
enum ItemActType {
VOTE
BOOST
TIP
STREAM
POLL
DONT_LIKE_THIS
FEE
}
enum WithdrawlStatus {
INSUFFICIENT_BALANCE
INVALID_PAYMENT
PATHFINDING_TIMEOUT
ROUTE_NOT_FOUND
CONFIRMED
UNKNOWN_FAILURE
Service worker rework, Web Target Share API & Web Push API (#324) * npm uninstall next-pwa next-pwa was last updated in August 2022. There is also an issue which mentions that next-pwa is abandoned (?): https://github.com/shadowwalker/next-pwa/issues/482 But the main reason for me uninstalling it is that it adds a lot of preconfigured stuff which is not necessary for us. It even lead to a bug since pages were cached without our knowledge. So I will go with a different PWA approach. This different approach should do the following: - make it more transparent what the service worker is doing - gives us more control to configure the service worker and thus making it easier * Use workbox-webpack-plugin Every other plugin (`next-offline`, `next-workbox-webpack-plugin`, `next-with-workbox`, ...) added unnecessary configuration which felt contrary to how PWAs should be built. (PWAs should progressivly enhance the website in small steps, see https://web.dev/learn/pwa/getting-started/#focus-on-a-feature) These default configurations even lead to worse UX since they made invalid assumptions about stacker.news: We _do not_ want to cache our start url and we _do not_ want to cache anything unless explicitly told to. Almost every page on SN should be fresh for the best UX. To achieve this, by default, the service worker falls back to the network (as if the service worker wasn't there). Therefore, this should be the simplest configuration with a valid precache and cache busting support. In the future, we can try to use prefetching to improve performance of navigation requests. * Add support for Web Share Target API See https://developer.chrome.com/articles/web-share-target/ * Use Web Push API for push notifications I followed this (very good!) guide: https://web.dev/notifications/ * Refactor code related to Web Push * Send push notification to users on events * Merge notifications * Send notification to author of every parent recursively * Remove unused userId param in savePushSubscription As it should be, the user id is retrieved from the authenticated user in the backend. * Resubscribe user if push subscription changed * Update old subscription if oldEndpoint was given * Allow users to unsubscribe * Use LTREE operator instead of recursive query * Always show checkbox for push notifications * Justify checkbox to end * Update title of first push notification * Fix warning from uncontrolled to controlled * Add comment about Notification.requestPermission * Fix timestamp * Catch error on push subscription toggle * Wrap function bodies in try/catch * Use Promise.allSettled * Filter subscriptions by user notification settings * Fix user notification filter * Use skipWaiting --------- Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 19:36:07 +00:00
}
enum LogLevel {
DEBUG
INFO
WARN
ERROR
2023-09-28 20:02:25 +00:00
}