Skip to content

Commit 89e1837

Browse files
authored
Merge branch 'master' into user_deletion
2 parents 13bab6d + bfced69 commit 89e1837

34 files changed

+713
-459
lines changed

api/resolvers/item.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ import { verifyHmac } from './wallet'
2828
import { parse } from 'tldts'
2929
import { shuffleArray } from '@/lib/rand'
3030

31-
metadataRuleSets.title.rules.unshift(['h1 > yt-formatted-string.ytd-watch-metadata', el => el.getAttribute('title')])
32-
3331
function commentsOrderByClause (me, models, sort) {
3432
const sharedSortsArray = []
3533
sharedSortsArray.push('("Item"."pinId" IS NOT NULL) DESC')
3634
sharedSortsArray.push('("Item"."deletedAt" IS NULL) DESC')
35+
// outlawed items should be at the bottom
36+
sharedSortsArray.push(`NOT ("Item"."weightedVotes" - "Item"."weightedDownVotes" <= -${ITEM_FILTER_THRESHOLD} OR "Item".outlawed) DESC`)
3737
const sharedSorts = sharedSortsArray.join(', ')
3838

3939
if (sort === 'recent') {
@@ -595,7 +595,13 @@ export default {
595595
const response = await fetch(ensureProtocol(url), { redirect: 'follow' })
596596
const html = await response.text()
597597
const doc = domino.createWindow(html).document
598-
const metadata = getMetadata(doc, url, { title: metadataRuleSets.title, publicationDate: publicationDateRuleSet })
598+
const titleRuleSet = {
599+
rules: [
600+
['h1 > yt-formatted-string.ytd-watch-metadata', el => el.getAttribute('title')],
601+
...metadataRuleSets.title.rules
602+
]
603+
}
604+
const metadata = getMetadata(doc, url, { title: titleRuleSet, publicationDate: publicationDateRuleSet })
599605
const dateHint = ` (${metadata.publicationDate?.getFullYear()})`
600606
const moreThanOneYearAgo = metadata.publicationDate && metadata.publicationDate < datePivot(new Date(), { years: -1 })
601607

api/resolvers/notifications.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { decodeCursor, LIMIT, nextNoteCursorEncoded } from '@/lib/cursor'
22
import { getItem, filterClause, whereClause, muteClause, activeOrMine } from './item'
33
import { getInvoice, getWithdrawl } from './wallet'
44
import { pushSubscriptionSchema, validateSchema } from '@/lib/validate'
5-
import { replyToSubscription } from '@/lib/webPush'
5+
import { sendPushSubscriptionReply } from '@/lib/webPush'
66
import { getSub } from './sub'
77
import { GqlAuthenticationError, GqlInputError } from '@/lib/error'
88
import { WALLET_MAX_RETRIES, WALLET_RETRY_BEFORE_MS } from '@/lib/constants'
@@ -439,7 +439,7 @@ export default {
439439
console.log(`[webPush] created subscription for user ${me.id}: endpoint=${endpoint}`)
440440
}
441441

442-
await replyToSubscription(dbPushSubscription.id, { title: 'Stacker News notifications are now active' })
442+
await sendPushSubscriptionReply(dbPushSubscription)
443443

444444
return dbPushSubscription
445445
},

api/resolvers/wallet.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import walletDefs from '@/wallets/server'
2222
import { generateResolverName, generateTypeDefName } from '@/wallets/graphql'
2323
import { lnAddrOptions } from '@/lib/lnurl'
2424
import { GqlAuthenticationError, GqlAuthorizationError, GqlInputError } from '@/lib/error'
25-
import { getNodeSockets, getOurPubkey } from '../lnd'
25+
import { getNodeSockets } from '../lnd'
2626
import validateWallet from '@/wallets/validate'
2727
import { canReceive, getWalletByType } from '@/wallets/common'
2828
import performPaidAction from '../paidAction'
@@ -987,7 +987,7 @@ export async function createWithdrawal (parent, { invoice, maxFee }, { me, model
987987
return await performPayingAction({ bolt11: invoice, maxFee, walletId: wallet?.id }, { me, models, lnd })
988988
}
989989

990-
export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...payer },
990+
async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...payer },
991991
{ me, models, lnd, headers }) {
992992
if (!me) {
993993
throw new GqlAuthenticationError()
@@ -1005,11 +1005,9 @@ export async function sendToLnAddr (parent, { addr, amount, maxFee, comment, ...
10051005
return await createWithdrawal(parent, { invoice: res.pr, maxFee }, { me, models, lnd, headers })
10061006
}
10071007

1008-
export async function fetchLnAddrInvoice (
1008+
async function fetchLnAddrInvoice (
10091009
{ addr, amount, maxFee, comment, ...payer },
1010-
{
1011-
me, models, lnd, autoWithdraw = false
1012-
}) {
1010+
{ me, models, lnd }) {
10131011
const options = await lnAddrOptions(addr)
10141012
await validateSchema(lnAddrSchema, { addr, amount, maxFee, comment, ...payer }, options)
10151013

@@ -1046,14 +1044,6 @@ export async function fetchLnAddrInvoice (
10461044
// decode invoice
10471045
try {
10481046
const decoded = await parsePaymentRequest({ request: res.pr })
1049-
const ourPubkey = await getOurPubkey({ lnd })
1050-
if (autoWithdraw && decoded.destination === ourPubkey && process.env.NODE_ENV === 'production') {
1051-
// unset lnaddr so we don't trigger another withdrawal with same destination
1052-
await models.wallet.deleteMany({
1053-
where: { userId: me.id, type: 'LIGHTNING_ADDRESS' }
1054-
})
1055-
throw new Error('automated withdrawals to other stackers are not allowed')
1056-
}
10571047
if (!decoded.mtokens || BigInt(decoded.mtokens) !== BigInt(milliamount)) {
10581048
throw new Error('invoice has incorrect amount')
10591049
}

api/slack/index.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

api/typeDefs/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default gql`
8888
8989
input SettingsInput {
9090
autoDropBolt11s: Boolean!
91-
diagnostics: Boolean!
91+
diagnostics: Boolean @deprecated
9292
noReferralLinks: Boolean!
9393
fiatCurrency: String!
9494
satsFilter: Int!
@@ -164,7 +164,7 @@ export default gql`
164164
mirrors SettingsInput
165165
"""
166166
autoDropBolt11s: Boolean!
167-
diagnostics: Boolean!
167+
diagnostics: Boolean @deprecated
168168
noReferralLinks: Boolean!
169169
fiatCurrency: String!
170170
satsFilter: Int!

0 commit comments

Comments
 (0)