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 {
|
2024-01-07 17:00:24 +00:00
|
|
|
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")
|
2024-05-04 23:06:15 +00:00
|
|
|
emailHash String? @unique(map: "users.email_hash_unique")
|
2024-01-07 17:00:24 +00:00
|
|
|
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")
|
2024-03-26 18:26:09 +00:00
|
|
|
apiKeyHash String? @unique(map: "users.apikeyhash_unique") @db.Char(64)
|
2024-03-14 20:32:34 +00:00
|
|
|
apiKeyEnabled Boolean @default(false)
|
2024-01-07 17:00:24 +00:00
|
|
|
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)
|
2024-03-25 20:20:11 +00:00
|
|
|
noteWithdrawals Boolean @default(true)
|
2024-01-07 17:00:24 +00:00
|
|
|
noteEarning Boolean @default(true)
|
|
|
|
noteInvites Boolean @default(true)
|
|
|
|
noteItemSats Boolean @default(true)
|
|
|
|
noteMentions Boolean @default(true)
|
2024-06-03 17:12:42 +00:00
|
|
|
noteItemMentions Boolean @default(true)
|
2024-01-07 17:00:24 +00:00
|
|
|
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)
|
2024-02-10 02:35:32 +00:00
|
|
|
nsfwMode Boolean @default(false)
|
2024-01-07 17:00:24 +00:00
|
|
|
fiatCurrency String @default("USD")
|
|
|
|
withdrawMaxFeeDefault Int @default(10)
|
|
|
|
autoDropBolt11s Boolean @default(false)
|
|
|
|
hideFromTopUsers Boolean @default(false)
|
|
|
|
turboTipping Boolean @default(false)
|
2024-03-25 00:46:12 +00:00
|
|
|
zapUndos Int?
|
2024-01-07 17:00:24 +00:00
|
|
|
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[]
|
|
|
|
PushSubscriptions PushSubscription[]
|
|
|
|
ReferralAct ReferralAct[]
|
|
|
|
Streak Streak[]
|
|
|
|
ThreadSubscriptions ThreadSubscription[]
|
2024-02-23 15:12:49 +00:00
|
|
|
SubSubscriptions SubSubscription[]
|
2024-01-07 17:00:24 +00:00
|
|
|
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)
|
2024-02-14 19:33:31 +00:00
|
|
|
hideGithub Boolean @default(true)
|
|
|
|
hideNostr Boolean @default(true)
|
|
|
|
hideTwitter Boolean @default(true)
|
2024-03-17 14:57:50 +00:00
|
|
|
noReferralLinks Boolean @default(false)
|
2024-02-14 19:33:31 +00:00
|
|
|
githubId String?
|
|
|
|
twitterId String?
|
2024-01-07 17:00:24 +00:00
|
|
|
followers UserSubscription[] @relation("follower")
|
|
|
|
followees UserSubscription[] @relation("followee")
|
|
|
|
hideWelcomeBanner Boolean @default(false)
|
|
|
|
diagnostics Boolean @default(false)
|
|
|
|
hideIsContributor Boolean @default(false)
|
|
|
|
lnAddr String?
|
|
|
|
autoWithdrawMaxFeePercent Float?
|
|
|
|
autoWithdrawThreshold Int?
|
|
|
|
muters Mute[] @relation("muter")
|
|
|
|
muteds Mute[] @relation("muted")
|
|
|
|
ArcOut Arc[] @relation("fromUser")
|
|
|
|
ArcIn Arc[] @relation("toUser")
|
|
|
|
Sub Sub[]
|
|
|
|
SubAct SubAct[]
|
|
|
|
MuteSub MuteSub[]
|
2024-02-13 19:17:56 +00:00
|
|
|
Wallet Wallet[]
|
2024-03-24 04:15:00 +00:00
|
|
|
TerritoryTransfers TerritoryTransfer[] @relation("TerritoryTransfer_oldUser")
|
|
|
|
TerritoryReceives TerritoryTransfer[] @relation("TerritoryTransfer_newUser")
|
|
|
|
AncestorReplies Reply[] @relation("AncestorReplyUser")
|
|
|
|
Replies Reply[]
|
Wallet Logs (#994)
* nwc wallet logs
* persist logs in IndexedDB
* Potential fix for empty error message
* load logs limited to 5m ago from IDB
* load logs from past via query param
* Add 5m, 1h, 6h links for earlier logs
* Show end of log
* Clamp to logStart
* Add log.module.css
* Remove TODO about persistence
* Use table for logs
* <table> fixes bad format with fixed width and message overflow into start of next row
* also using ---start of log--- instead of ---end of log--- now
* removed time string in header nav
* Rename .header to .logNav
* Simply load all logs and remove navigation
I realized the code for navigation was most likely premature optimization which even resulted in worse UX:
Using the buttons to load logs from 5m, 1h, 6h ago sometimes meant that nothing happened at all since there were no logs from 5m, 1h, 6h ago.
That's why I added a time string as "start of logs" so it's at least visible that it changed but that looked bad so I removed it.
But all of this was not necessary: I can simply load all logs at once and then the user can scroll around however they like.
I was worried that it would be bad for performance to load all logs at once since we might store a lot of logs but as mentioned, that's probably premature optimization.
WHEN a lot of logs are stored AND this becomes a problem (What problem even? Slow page load?), THEN we can think about this.
If page load ever becomes slow because of loading logs, we could probably simply not load the logs at page load but only when /wallet/logs is visited.
But for now, this works fine.
* Add follow checkbox
* Create WalletLogs component
* Embed wallet logs
* Remove test error
* Fix level padding
* Add LNbits logs
* Add logs for attaching LND and lnAddr
* Use err.message || err.toString?.() consistently
* Autowithdrawal logs
* Use details from LND error
* Don't log test invoice individually
* Also refetch logs on error
* Remove obsolete and annoying toasts
* Replace scrollIntoView with scroll
* Use constant embedded max-height
* Fix missing width: 100% for embedded logs
* Show full payment hash and preimage in logs
* Also parse details from LND errors on autowithdrawal failures
* Remove TODO
* Fix accidental removal of wss:// check
* Fix alignment of start marker and show empty if empty
* Fix sendPayment loop
* Split context in two
2024-04-03 22:27:21 +00:00
|
|
|
walletLogs WalletLog[]
|
2024-05-19 20:52:02 +00:00
|
|
|
Reminder Reminder[]
|
2024-06-03 18:56:43 +00:00
|
|
|
PollBlindVote PollBlindVote[]
|
2024-07-01 17:02:29 +00:00
|
|
|
ItemUserAgg ItemUserAgg[]
|
2022-08-06 22:03:57 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-02-13 19:17:56 +00:00
|
|
|
enum WalletType {
|
|
|
|
LIGHTNING_ADDRESS
|
|
|
|
LND
|
2024-04-14 22:34:21 +00:00
|
|
|
CLN
|
2024-02-13 19:17:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model Wallet {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
userId Int
|
|
|
|
label String?
|
|
|
|
priority Int @default(0)
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
// NOTE: this denormalized json field exists to make polymorphic joins efficient
|
|
|
|
// when reading wallets ... it is populated by a trigger when wallet descendants update
|
|
|
|
// otherwise reading wallets would require a join on every descendant table
|
|
|
|
// which might not be numerous for wallets but would be for other tables
|
|
|
|
// so this is a pattern we use only to be consistent with future polymorphic tables
|
|
|
|
// because it gives us fast reads and type safe writes
|
|
|
|
type WalletType
|
|
|
|
wallet Json? @db.JsonB
|
|
|
|
walletLightningAddress WalletLightningAddress?
|
|
|
|
walletLND WalletLND?
|
2024-04-14 22:34:21 +00:00
|
|
|
walletCLN WalletCLN?
|
2024-04-16 18:59:46 +00:00
|
|
|
withdrawals Withdrawl[]
|
2024-02-13 19:17:56 +00:00
|
|
|
|
|
|
|
@@index([userId])
|
|
|
|
}
|
|
|
|
|
Wallet Logs (#994)
* nwc wallet logs
* persist logs in IndexedDB
* Potential fix for empty error message
* load logs limited to 5m ago from IDB
* load logs from past via query param
* Add 5m, 1h, 6h links for earlier logs
* Show end of log
* Clamp to logStart
* Add log.module.css
* Remove TODO about persistence
* Use table for logs
* <table> fixes bad format with fixed width and message overflow into start of next row
* also using ---start of log--- instead of ---end of log--- now
* removed time string in header nav
* Rename .header to .logNav
* Simply load all logs and remove navigation
I realized the code for navigation was most likely premature optimization which even resulted in worse UX:
Using the buttons to load logs from 5m, 1h, 6h ago sometimes meant that nothing happened at all since there were no logs from 5m, 1h, 6h ago.
That's why I added a time string as "start of logs" so it's at least visible that it changed but that looked bad so I removed it.
But all of this was not necessary: I can simply load all logs at once and then the user can scroll around however they like.
I was worried that it would be bad for performance to load all logs at once since we might store a lot of logs but as mentioned, that's probably premature optimization.
WHEN a lot of logs are stored AND this becomes a problem (What problem even? Slow page load?), THEN we can think about this.
If page load ever becomes slow because of loading logs, we could probably simply not load the logs at page load but only when /wallet/logs is visited.
But for now, this works fine.
* Add follow checkbox
* Create WalletLogs component
* Embed wallet logs
* Remove test error
* Fix level padding
* Add LNbits logs
* Add logs for attaching LND and lnAddr
* Use err.message || err.toString?.() consistently
* Autowithdrawal logs
* Use details from LND error
* Don't log test invoice individually
* Also refetch logs on error
* Remove obsolete and annoying toasts
* Replace scrollIntoView with scroll
* Use constant embedded max-height
* Fix missing width: 100% for embedded logs
* Show full payment hash and preimage in logs
* Also parse details from LND errors on autowithdrawal failures
* Remove TODO
* Fix accidental removal of wss:// check
* Fix alignment of start marker and show empty if empty
* Fix sendPayment loop
* Split context in two
2024-04-03 22:27:21 +00:00
|
|
|
model WalletLog {
|
2024-05-19 20:52:02 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
Wallet Logs (#994)
* nwc wallet logs
* persist logs in IndexedDB
* Potential fix for empty error message
* load logs limited to 5m ago from IDB
* load logs from past via query param
* Add 5m, 1h, 6h links for earlier logs
* Show end of log
* Clamp to logStart
* Add log.module.css
* Remove TODO about persistence
* Use table for logs
* <table> fixes bad format with fixed width and message overflow into start of next row
* also using ---start of log--- instead of ---end of log--- now
* removed time string in header nav
* Rename .header to .logNav
* Simply load all logs and remove navigation
I realized the code for navigation was most likely premature optimization which even resulted in worse UX:
Using the buttons to load logs from 5m, 1h, 6h ago sometimes meant that nothing happened at all since there were no logs from 5m, 1h, 6h ago.
That's why I added a time string as "start of logs" so it's at least visible that it changed but that looked bad so I removed it.
But all of this was not necessary: I can simply load all logs at once and then the user can scroll around however they like.
I was worried that it would be bad for performance to load all logs at once since we might store a lot of logs but as mentioned, that's probably premature optimization.
WHEN a lot of logs are stored AND this becomes a problem (What problem even? Slow page load?), THEN we can think about this.
If page load ever becomes slow because of loading logs, we could probably simply not load the logs at page load but only when /wallet/logs is visited.
But for now, this works fine.
* Add follow checkbox
* Create WalletLogs component
* Embed wallet logs
* Remove test error
* Fix level padding
* Add LNbits logs
* Add logs for attaching LND and lnAddr
* Use err.message || err.toString?.() consistently
* Autowithdrawal logs
* Use details from LND error
* Don't log test invoice individually
* Also refetch logs on error
* Remove obsolete and annoying toasts
* Replace scrollIntoView with scroll
* Use constant embedded max-height
* Fix missing width: 100% for embedded logs
* Show full payment hash and preimage in logs
* Also parse details from LND errors on autowithdrawal failures
* Remove TODO
* Fix accidental removal of wss:// check
* Fix alignment of start marker and show empty if empty
* Fix sendPayment loop
* Split context in two
2024-04-03 22:27:21 +00:00
|
|
|
userId Int
|
2024-05-19 20:52:02 +00:00
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
2024-05-03 19:14:33 +00:00
|
|
|
wallet WalletType
|
Wallet Logs (#994)
* nwc wallet logs
* persist logs in IndexedDB
* Potential fix for empty error message
* load logs limited to 5m ago from IDB
* load logs from past via query param
* Add 5m, 1h, 6h links for earlier logs
* Show end of log
* Clamp to logStart
* Add log.module.css
* Remove TODO about persistence
* Use table for logs
* <table> fixes bad format with fixed width and message overflow into start of next row
* also using ---start of log--- instead of ---end of log--- now
* removed time string in header nav
* Rename .header to .logNav
* Simply load all logs and remove navigation
I realized the code for navigation was most likely premature optimization which even resulted in worse UX:
Using the buttons to load logs from 5m, 1h, 6h ago sometimes meant that nothing happened at all since there were no logs from 5m, 1h, 6h ago.
That's why I added a time string as "start of logs" so it's at least visible that it changed but that looked bad so I removed it.
But all of this was not necessary: I can simply load all logs at once and then the user can scroll around however they like.
I was worried that it would be bad for performance to load all logs at once since we might store a lot of logs but as mentioned, that's probably premature optimization.
WHEN a lot of logs are stored AND this becomes a problem (What problem even? Slow page load?), THEN we can think about this.
If page load ever becomes slow because of loading logs, we could probably simply not load the logs at page load but only when /wallet/logs is visited.
But for now, this works fine.
* Add follow checkbox
* Create WalletLogs component
* Embed wallet logs
* Remove test error
* Fix level padding
* Add LNbits logs
* Add logs for attaching LND and lnAddr
* Use err.message || err.toString?.() consistently
* Autowithdrawal logs
* Use details from LND error
* Don't log test invoice individually
* Also refetch logs on error
* Remove obsolete and annoying toasts
* Replace scrollIntoView with scroll
* Use constant embedded max-height
* Fix missing width: 100% for embedded logs
* Show full payment hash and preimage in logs
* Also parse details from LND errors on autowithdrawal failures
* Remove TODO
* Fix accidental removal of wss:// check
* Fix alignment of start marker and show empty if empty
* Fix sendPayment loop
* Split context in two
2024-04-03 22:27:21 +00:00
|
|
|
level LogLevel
|
|
|
|
message String
|
|
|
|
|
|
|
|
@@index([userId, createdAt])
|
|
|
|
}
|
|
|
|
|
2024-02-13 19:17:56 +00:00
|
|
|
model WalletLightningAddress {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
walletId Int @unique
|
|
|
|
wallet Wallet @relation(fields: [walletId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
address String
|
|
|
|
}
|
|
|
|
|
|
|
|
model WalletLND {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
walletId Int @unique
|
|
|
|
wallet Wallet @relation(fields: [walletId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
socket String
|
|
|
|
macaroon String
|
|
|
|
cert String?
|
|
|
|
}
|
|
|
|
|
2024-04-14 22:34:21 +00:00
|
|
|
model WalletCLN {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
walletId Int @unique
|
|
|
|
wallet Wallet @relation(fields: [walletId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
socket String
|
|
|
|
rune String
|
|
|
|
cert String?
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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")
|
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 {
|
2024-07-01 17:02:29 +00:00
|
|
|
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?
|
|
|
|
invoiceId Int?
|
|
|
|
invoiceActionState InvoiceActionState?
|
|
|
|
invoice Invoice? @relation(fields: [invoiceId], references: [id], onDelete: SetNull)
|
|
|
|
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")
|
2024-07-01 17:02:29 +00:00
|
|
|
@@index([invoiceId])
|
2022-09-12 18:55:34 +00:00
|
|
|
}
|
|
|
|
|
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)
|
2022-09-12 18:55:34 +00:00
|
|
|
|
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 {
|
2024-07-01 17:02:29 +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?
|
|
|
|
lastZapAt 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?
|
|
|
|
imgproxyUrls Json?
|
|
|
|
bounty Int?
|
|
|
|
noteId String? @unique(map: "Item.noteId_unique")
|
|
|
|
rootId Int?
|
|
|
|
bountyPaidTo Int[]
|
|
|
|
upvotes Int @default(0)
|
|
|
|
weightedComments Float @default(0)
|
|
|
|
Bookmark Bookmark[]
|
|
|
|
parent Item? @relation("ParentChildren", fields: [parentId], references: [id])
|
|
|
|
children Item[] @relation("ParentChildren")
|
|
|
|
pin Pin? @relation(fields: [pinId], references: [id])
|
|
|
|
root Item? @relation("RootDescendant", fields: [rootId], references: [id])
|
|
|
|
descendants Item[] @relation("RootDescendant")
|
|
|
|
sub Sub? @relation(fields: [subName], references: [name], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
user User @relation("UserItems", fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
itemActs ItemAct[]
|
|
|
|
mentions Mention[]
|
|
|
|
itemReferrers ItemMention[] @relation("referrer")
|
|
|
|
itemReferees ItemMention[] @relation("referee")
|
|
|
|
pollOptions PollOption[]
|
|
|
|
PollVote PollVote[]
|
|
|
|
threadSubscriptions ThreadSubscription[]
|
|
|
|
User User[]
|
|
|
|
itemForwards ItemForward[]
|
|
|
|
itemUploads ItemUpload[]
|
|
|
|
uploadId Int?
|
|
|
|
invoiceId Int?
|
|
|
|
invoiceActionState InvoiceActionState?
|
|
|
|
invoicePaidAt DateTime?
|
|
|
|
outlawed Boolean @default(false)
|
|
|
|
apiKey Boolean @default(false)
|
|
|
|
pollExpiresAt DateTime?
|
|
|
|
Ancestors Reply[] @relation("AncestorReplyItem")
|
|
|
|
Replies Reply[]
|
|
|
|
Reminder Reminder[]
|
|
|
|
invoice Invoice? @relation(fields: [invoiceId], references: [id], onDelete: SetNull)
|
|
|
|
PollBlindVote PollBlindVote[]
|
|
|
|
ItemUserAgg ItemUserAgg[]
|
2022-08-06 22:03:57 +00:00
|
|
|
|
2023-11-06 20:53:33 +00:00
|
|
|
@@index([uploadId])
|
2024-03-24 19:16:29 +00:00
|
|
|
@@index([lastZapAt])
|
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")
|
2024-07-01 17:02:29 +00:00
|
|
|
@@index([invoiceId])
|
|
|
|
}
|
|
|
|
|
|
|
|
// we use this to denormalize a user's aggregated interactions (zaps) with an item
|
|
|
|
// we need to do this to safely modify the aggregates in a read committed transaction
|
|
|
|
// because we can't lock an aggregate query to guard a potentially conflicting update
|
|
|
|
// (e.g. sum("ItemAct".msats), but we can lock a row where we store the aggregate
|
|
|
|
// this is important because zaps do not update "weightedVotes" linearly
|
|
|
|
// see: https://stackoverflow.com/questions/61781595/postgres-read-commited-doesnt-re-read-updated-row?noredirect=1#comment109279507_61781595
|
|
|
|
// or: https://www.cybertec-postgresql.com/en/transaction-anomalies-with-select-for-update/
|
|
|
|
model ItemUserAgg {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
itemId Int
|
|
|
|
userId Int
|
|
|
|
zapSats BigInt @default(0)
|
|
|
|
downZapSats BigInt @default(0)
|
|
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
@@unique([itemId, userId])
|
|
|
|
@@index([itemId])
|
|
|
|
@@index([userId])
|
|
|
|
@@index([createdAt])
|
2021-03-25 19:29:24 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 04:15:00 +00:00
|
|
|
// this is a denomalized table that is used to make reply notifications
|
|
|
|
// more efficient ... it is populated by a trigger when replies are created
|
|
|
|
model Reply {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
ancestorId Int
|
|
|
|
ancestorUserId Int
|
|
|
|
itemId Int
|
|
|
|
userId Int
|
|
|
|
level Int
|
|
|
|
User User @relation(fields: [userId], references: [id])
|
|
|
|
Item Item @relation(fields: [itemId], references: [id])
|
|
|
|
AncestorUser User @relation("AncestorReplyUser", fields: [ancestorUserId], references: [id])
|
|
|
|
AncestorItem Item @relation("AncestorReplyItem", fields: [ancestorId], references: [id])
|
|
|
|
|
|
|
|
@@index([ancestorId])
|
|
|
|
@@index([ancestorUserId])
|
2024-03-24 19:16:29 +00:00
|
|
|
@@index([itemId])
|
|
|
|
@@index([userId])
|
2024-03-24 04:15:00 +00:00
|
|
|
@@index([level])
|
|
|
|
@@index([createdAt])
|
|
|
|
}
|
|
|
|
|
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 {
|
2024-07-01 17:02:29 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
itemId Int
|
|
|
|
pollOptionId Int
|
|
|
|
invoiceId Int?
|
|
|
|
invoiceActionState InvoiceActionState?
|
|
|
|
invoice Invoice? @relation(fields: [invoiceId], references: [id], onDelete: SetNull)
|
|
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
|
|
pollOption PollOption @relation(fields: [pollOptionId], references: [id], onDelete: Cascade)
|
2022-07-30 13:25:46 +00:00
|
|
|
|
2023-07-26 16:01:31 +00:00
|
|
|
@@index([pollOptionId], map: "PollVote.pollOptionId_index")
|
2024-07-01 17:02:29 +00:00
|
|
|
@@index([invoiceId])
|
2024-06-03 18:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model PollBlindVote {
|
2024-07-01 17:02:29 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
itemId Int
|
|
|
|
userId Int
|
|
|
|
invoiceId Int?
|
|
|
|
invoiceActionState InvoiceActionState?
|
|
|
|
invoice Invoice? @relation(fields: [invoiceId], references: [id], onDelete: SetNull)
|
|
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
2024-06-03 18:56:43 +00:00
|
|
|
|
|
|
|
@@unique([itemId, userId], map: "PollBlindVote.itemId_userId_unique")
|
|
|
|
@@index([userId], map: "PollBlindVote.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
|
2023-12-10 21:41:20 +00:00
|
|
|
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)
|
2024-01-03 02:05:49 +00:00
|
|
|
statusUpdatedAt DateTime?
|
2023-12-08 20:02:00 +00:00
|
|
|
billingType BillingType
|
|
|
|
billingCost Int
|
|
|
|
billingAutoRenew Boolean @default(false)
|
|
|
|
billedLastAt DateTime @default(now())
|
2024-02-16 18:25:12 +00:00
|
|
|
billPaidUntil DateTime?
|
2023-12-23 20:26:16 +00:00
|
|
|
moderated Boolean @default(false)
|
|
|
|
moderatedCount Int @default(0)
|
2024-02-10 02:35:32 +00:00
|
|
|
nsfw Boolean @default(false)
|
2023-11-21 23:32:22 +00:00
|
|
|
|
2024-03-24 04:15:00 +00:00
|
|
|
parent Sub? @relation("ParentChildren", fields: [parentName], references: [name])
|
|
|
|
children Sub[] @relation("ParentChildren")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
Item Item[]
|
|
|
|
SubAct SubAct[]
|
|
|
|
MuteSub MuteSub[]
|
|
|
|
SubSubscription SubSubscription[]
|
2024-03-05 19:56:02 +00:00
|
|
|
TerritoryTransfer TerritoryTransfer[]
|
2023-11-21 23:32:22 +00:00
|
|
|
|
|
|
|
@@index([parentName])
|
|
|
|
@@index([createdAt])
|
|
|
|
@@index([userId])
|
2024-01-03 02:05:49 +00:00
|
|
|
@@index([statusUpdatedAt])
|
2023-11-21 23:32:22 +00:00
|
|
|
@@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)
|
2024-01-11 23:45:17 +00:00
|
|
|
sub Sub @relation(fields: [subName], references: [name], onDelete: Cascade, onUpdate: Cascade)
|
2023-11-21 23:32:22 +00:00
|
|
|
|
|
|
|
@@index([userId])
|
|
|
|
@@index([userId, type])
|
|
|
|
@@index([type])
|
|
|
|
@@index([createdAt])
|
|
|
|
@@index([createdAt, type])
|
|
|
|
@@index([userId, createdAt, type])
|
2023-05-01 20:58:30 +00:00
|
|
|
}
|
|
|
|
|
2023-12-15 18:10:29 +00:00
|
|
|
model MuteSub {
|
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
|
2024-01-11 23:45:17 +00:00
|
|
|
sub Sub @relation(fields: [subName], references: [name], onDelete: Cascade, onUpdate: Cascade)
|
2023-07-26 16:01:31 +00:00
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
2023-12-15 18:10:29 +00:00
|
|
|
|
|
|
|
@@id([userId, subName])
|
|
|
|
@@index([subName])
|
|
|
|
@@index([createdAt])
|
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 {
|
2024-07-01 17:02:29 +00:00
|
|
|
id Int @id(map: "Vote_pkey") @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
msats BigInt
|
|
|
|
act ItemActType
|
|
|
|
itemId Int
|
|
|
|
userId Int
|
|
|
|
invoiceId Int?
|
|
|
|
invoiceActionState InvoiceActionState?
|
|
|
|
|
|
|
|
invoice Invoice? @relation(fields: [invoiceId], references: [id], onDelete: SetNull)
|
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")
|
2024-07-01 17:02:29 +00:00
|
|
|
@@index([invoiceId])
|
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
|
|
|
}
|
|
|
|
|
2024-07-01 17:02:29 +00:00
|
|
|
enum InvoiceActionType {
|
|
|
|
BUY_CREDITS
|
|
|
|
ITEM_CREATE
|
|
|
|
ITEM_UPDATE
|
|
|
|
ZAP
|
|
|
|
DOWN_ZAP
|
|
|
|
DONATE
|
|
|
|
POLL_VOTE
|
|
|
|
TERRITORY_CREATE
|
|
|
|
TERRITORY_UPDATE
|
|
|
|
TERRITORY_BILLING
|
|
|
|
TERRITORY_UNARCHIVE
|
|
|
|
}
|
|
|
|
|
|
|
|
enum InvoiceActionState {
|
|
|
|
PENDING
|
|
|
|
PENDING_HELD
|
|
|
|
HELD
|
|
|
|
PAID
|
|
|
|
FAILED
|
|
|
|
RETRYING
|
|
|
|
}
|
|
|
|
|
2024-06-03 17:12:42 +00:00
|
|
|
model ItemMention {
|
2024-07-01 17:02:29 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
|
|
|
|
referrerId Int
|
|
|
|
refereeId Int
|
|
|
|
referrerItem Item @relation("referrer", fields: [referrerId], references: [id], onDelete: Cascade)
|
|
|
|
refereeItem Item @relation("referee", fields: [refereeId], references: [id], onDelete: Cascade)
|
2024-06-03 17:12:42 +00:00
|
|
|
|
|
|
|
@@unique([referrerId, refereeId], map: "ItemMention.referrerId_refereeId_unique")
|
|
|
|
@@index([createdAt], map: "ItemMention.created_at_index")
|
|
|
|
@@index([referrerId], map: "ItemMention.referrerId_index")
|
|
|
|
@@index([refereeId], map: "ItemMention.refereeId_index")
|
|
|
|
}
|
|
|
|
|
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")
|
2023-08-31 02:48:49 +00:00
|
|
|
preimage String? @unique(map: "Invoice.preimage_unique")
|
|
|
|
isHeld Boolean?
|
2021-05-11 15:52:50 +00:00
|
|
|
bolt11 String
|
|
|
|
expiresAt DateTime
|
|
|
|
confirmedAt DateTime?
|
2024-01-08 22:37:58 +00:00
|
|
|
confirmedIndex BigInt?
|
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?
|
2023-09-24 01:14:49 +00:00
|
|
|
comment String?
|
2023-10-03 19:35:53 +00:00
|
|
|
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
|
|
|
|
2024-07-01 17:02:29 +00:00
|
|
|
actionState InvoiceActionState?
|
|
|
|
actionType InvoiceActionType?
|
|
|
|
actionId Int?
|
|
|
|
ItemAct ItemAct[]
|
|
|
|
Item Item[]
|
|
|
|
Upload Upload[]
|
|
|
|
PollVote PollVote[]
|
|
|
|
PollBlindVote PollBlindVote[]
|
|
|
|
|
2023-07-26 16:01:31 +00:00
|
|
|
@@index([createdAt], map: "Invoice.created_at_index")
|
|
|
|
@@index([userId], map: "Invoice.userId_index")
|
2024-01-08 22:37:58 +00:00
|
|
|
@@index([confirmedIndex], map: "Invoice.confirmedIndex_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
|
2023-11-09 17:50:43 +00:00
|
|
|
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?
|
2024-01-07 17:00:24 +00:00
|
|
|
autoWithdraw Boolean @default(false)
|
2024-04-16 18:59:46 +00:00
|
|
|
walletId Int?
|
2023-07-26 16:01:31 +00:00
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
2024-04-16 18:59:46 +00:00
|
|
|
wallet Wallet? @relation(fields: [walletId], references: [id], onDelete: SetNull)
|
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")
|
2024-07-01 17:02:29 +00:00
|
|
|
@@index([hash])
|
2021-05-12 23:04:19 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 19:29:24 +00:00
|
|
|
model Account {
|
2023-07-29 19:38:20 +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-29 19:38:20 +00:00
|
|
|
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?
|
|
|
|
|
2023-07-29 19:38:20 +00:00
|
|
|
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())
|
2023-07-29 19:38:20 +00:00
|
|
|
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
|
2023-07-29 19:38:20 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-07-29 19:38:20 +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
|
|
|
|
|
2023-07-29 19:38:20 +00:00
|
|
|
@@unique([identifier, token])
|
2023-07-26 16:01:31 +00:00
|
|
|
@@map("verification_requests")
|
2021-03-25 19:29:24 +00:00
|
|
|
}
|
2023-02-16 22:23:59 +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
|
|
|
|
2023-02-16 22:23:59 +00:00
|
|
|
@@id([userId, itemId])
|
2023-07-26 16:01:31 +00:00
|
|
|
@@index([createdAt], map: "Bookmark.created_at_index")
|
2023-02-16 22:23:59 +00:00
|
|
|
}
|
2023-06-01 00:44:06 +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 thread subscriptions for OP by default so they can
|
|
|
|
// unsubscribe from their own threads and its not a special case
|
2023-06-01 00:44:06 +00:00
|
|
|
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)
|
2023-06-01 00:44:06 +00:00
|
|
|
|
|
|
|
@@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
|
|
|
|
2023-08-29 01:27:56 +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)
|
2023-08-29 01:27:56 +00:00
|
|
|
|
|
|
|
@@id([followerId, followeeId])
|
|
|
|
@@index([createdAt], map: "UserSubscription.created_at_index")
|
|
|
|
@@index([followerId], map: "UserSubscription.follower_index")
|
|
|
|
@@index([followeeId], map: "UserSubscription.followee_index")
|
|
|
|
}
|
|
|
|
|
2024-02-23 15:12:49 +00:00
|
|
|
model SubSubscription {
|
|
|
|
userId Int
|
|
|
|
subName String @db.Citext
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
sub Sub @relation(fields: [subName], references: [name], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
|
|
|
|
@@id([userId, subName])
|
|
|
|
@@index([createdAt], map: "SubSubscription.created_at_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")
|
|
|
|
}
|
|
|
|
|
2023-09-18 23:00:16 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2024-03-05 19:56:02 +00:00
|
|
|
model TerritoryTransfer {
|
2024-03-24 04:15:00 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
oldUserId Int
|
|
|
|
newUserId Int
|
|
|
|
subName String @db.Citext
|
|
|
|
oldUser User @relation("TerritoryTransfer_oldUser", fields: [oldUserId], references: [id], onDelete: Cascade)
|
|
|
|
newUser User @relation("TerritoryTransfer_newUser", fields: [newUserId], references: [id], onDelete: Cascade)
|
|
|
|
sub Sub @relation(fields: [subName], references: [name], onDelete: Cascade)
|
2024-03-05 19:56:02 +00:00
|
|
|
|
|
|
|
@@index([createdAt, newUserId], map: "TerritoryTransfer.newUserId_index")
|
|
|
|
@@index([createdAt, oldUserId], map: "TerritoryTransfer.oldUserId_index")
|
|
|
|
}
|
|
|
|
|
2024-05-19 20:52:02 +00:00
|
|
|
model Reminder {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
userId Int
|
|
|
|
itemId Int
|
|
|
|
remindAt DateTime
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
@@index([userId, remindAt], map: "Reminder.userId_reminderAt_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
|
|
|
}
|
2023-09-18 23:00:16 +00:00
|
|
|
|
|
|
|
enum LogLevel {
|
|
|
|
DEBUG
|
|
|
|
INFO
|
|
|
|
WARN
|
|
|
|
ERROR
|
Wallet Logs (#994)
* nwc wallet logs
* persist logs in IndexedDB
* Potential fix for empty error message
* load logs limited to 5m ago from IDB
* load logs from past via query param
* Add 5m, 1h, 6h links for earlier logs
* Show end of log
* Clamp to logStart
* Add log.module.css
* Remove TODO about persistence
* Use table for logs
* <table> fixes bad format with fixed width and message overflow into start of next row
* also using ---start of log--- instead of ---end of log--- now
* removed time string in header nav
* Rename .header to .logNav
* Simply load all logs and remove navigation
I realized the code for navigation was most likely premature optimization which even resulted in worse UX:
Using the buttons to load logs from 5m, 1h, 6h ago sometimes meant that nothing happened at all since there were no logs from 5m, 1h, 6h ago.
That's why I added a time string as "start of logs" so it's at least visible that it changed but that looked bad so I removed it.
But all of this was not necessary: I can simply load all logs at once and then the user can scroll around however they like.
I was worried that it would be bad for performance to load all logs at once since we might store a lot of logs but as mentioned, that's probably premature optimization.
WHEN a lot of logs are stored AND this becomes a problem (What problem even? Slow page load?), THEN we can think about this.
If page load ever becomes slow because of loading logs, we could probably simply not load the logs at page load but only when /wallet/logs is visited.
But for now, this works fine.
* Add follow checkbox
* Create WalletLogs component
* Embed wallet logs
* Remove test error
* Fix level padding
* Add LNbits logs
* Add logs for attaching LND and lnAddr
* Use err.message || err.toString?.() consistently
* Autowithdrawal logs
* Use details from LND error
* Don't log test invoice individually
* Also refetch logs on error
* Remove obsolete and annoying toasts
* Replace scrollIntoView with scroll
* Use constant embedded max-height
* Fix missing width: 100% for embedded logs
* Show full payment hash and preimage in logs
* Also parse details from LND errors on autowithdrawal failures
* Remove TODO
* Fix accidental removal of wss:// check
* Fix alignment of start marker and show empty if empty
* Fix sendPayment loop
* Split context in two
2024-04-03 22:27:21 +00:00
|
|
|
SUCCESS
|
2023-09-28 20:02:25 +00:00
|
|
|
}
|