mirror of
https://github.com/KoalaSat/nostros.git
synced 2024-09-29 06:30:47 +00:00
fixed keys attribute missing on undefined error
This commit is contained in:
parent
6ab2a47d6c
commit
0d3dbd6791
@ -7,8 +7,8 @@ export interface DirectMessage extends Event {
|
|||||||
read: boolean
|
read: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const databaseToEntity: (object: any) => DirectMessage = (object) => {
|
const databaseToEntity: (object: any) => DirectMessage = (object = {}) => {
|
||||||
object.tags = JSON.parse(object.tags)
|
object.tags = object.tags ? JSON.parse(object.tags) : []
|
||||||
return object as DirectMessage
|
return object as DirectMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export const getGroupedDirectMessages: (
|
|||||||
},
|
},
|
||||||
) => Promise<DirectMessage[]> = async (db, { order = 'DESC' }) => {
|
) => Promise<DirectMessage[]> = async (db, { order = 'DESC' }) => {
|
||||||
let notesQuery = `
|
let notesQuery = `
|
||||||
SELECT
|
SELECT
|
||||||
*, MAX(created_at) AS request_id
|
*, MAX(created_at) AS request_id
|
||||||
FROM
|
FROM
|
||||||
nostros_direct_messages
|
nostros_direct_messages
|
||||||
@ -58,7 +58,7 @@ export const getDirectMessages: (
|
|||||||
{ order = 'DESC' },
|
{ order = 'DESC' },
|
||||||
) => {
|
) => {
|
||||||
const notesQuery = `
|
const notesQuery = `
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
nostros_direct_messages
|
nostros_direct_messages
|
||||||
|
@ -10,8 +10,8 @@ export interface Note extends Event {
|
|||||||
user_created_at: number
|
user_created_at: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const databaseToEntity: (object: any) => Note = (object) => {
|
const databaseToEntity: (object: any) => Note = (object = {}) => {
|
||||||
object.tags = JSON.parse(object.tags)
|
object.tags = object.tags ? JSON.parse(object.tags) : []
|
||||||
return object as Note
|
return object as Note
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,13 +21,13 @@ export const getMainNotes: (
|
|||||||
limit: number,
|
limit: number,
|
||||||
) => Promise<Note[]> = async (db, pubKey, limit) => {
|
) => Promise<Note[]> = async (db, pubKey, limit) => {
|
||||||
const notesQuery = `
|
const notesQuery = `
|
||||||
SELECT
|
SELECT
|
||||||
nostros_notes.*, nostros_users.lnurl, nostros_users.name, nostros_users.picture, nostros_users.contact, nostros_users.created_at as user_created_at FROM nostros_notes
|
nostros_notes.*, nostros_users.lnurl, nostros_users.name, nostros_users.picture, nostros_users.contact, nostros_users.created_at as user_created_at FROM nostros_notes
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
nostros_users ON nostros_users.id = nostros_notes.pubkey
|
nostros_users ON nostros_users.id = nostros_notes.pubkey
|
||||||
WHERE (nostros_users.contact = 1 OR nostros_notes.pubkey = '${pubKey}')
|
WHERE (nostros_users.contact = 1 OR nostros_notes.pubkey = '${pubKey}')
|
||||||
AND nostros_notes.main_event_id IS NULL
|
AND nostros_notes.main_event_id IS NULL
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
LIMIT ${limit}
|
LIMIT ${limit}
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -44,15 +44,15 @@ export const getMentionNotes: (
|
|||||||
limit: number,
|
limit: number,
|
||||||
) => Promise<Note[]> = async (db, pubKey, limit) => {
|
) => Promise<Note[]> = async (db, pubKey, limit) => {
|
||||||
const notesQuery = `
|
const notesQuery = `
|
||||||
SELECT
|
SELECT
|
||||||
nostros_notes.*, nostros_users.lnurl, nostros_users.name, nostros_users.picture, nostros_users.contact, nostros_users.created_at as user_created_at FROM nostros_notes
|
nostros_notes.*, nostros_users.lnurl, nostros_users.name, nostros_users.picture, nostros_users.contact, nostros_users.created_at as user_created_at FROM nostros_notes
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
nostros_users ON nostros_users.id = nostros_notes.pubkey
|
nostros_users ON nostros_users.id = nostros_notes.pubkey
|
||||||
WHERE (nostros_notes.reply_event_id IN (
|
WHERE (nostros_notes.reply_event_id IN (
|
||||||
SELECT nostros_notes.id FROM nostros_notes WHERE pubkey = '${pubKey}'
|
SELECT nostros_notes.id FROM nostros_notes WHERE pubkey = '${pubKey}'
|
||||||
) OR nostros_notes.user_mentioned = 1)
|
) OR nostros_notes.user_mentioned = 1)
|
||||||
AND nostros_notes.pubkey != '${pubKey}'
|
AND nostros_notes.pubkey != '${pubKey}'
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
LIMIT ${limit}
|
LIMIT ${limit}
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ export const getRepliesCount: (
|
|||||||
eventId: string,
|
eventId: string,
|
||||||
) => Promise<number> = async (db, eventId) => {
|
) => Promise<number> = async (db, eventId) => {
|
||||||
const repliesQuery = `
|
const repliesQuery = `
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(*)
|
COUNT(*)
|
||||||
FROM nostros_notes
|
FROM nostros_notes
|
||||||
WHERE reply_event_id = "${eventId}"
|
WHERE reply_event_id = "${eventId}"
|
||||||
@ -87,12 +87,12 @@ export const getLastReply: (
|
|||||||
) => Promise<Note> = async (db, { eventIds }) => {
|
) => Promise<Note> = async (db, { eventIds }) => {
|
||||||
const eventIdsQuery = eventIds.join('", "')
|
const eventIdsQuery = eventIds.join('", "')
|
||||||
const replyQuery = `
|
const replyQuery = `
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
nostros_notes
|
nostros_notes
|
||||||
WHERE reply_event_id IN ("${eventIdsQuery}")
|
WHERE reply_event_id IN ("${eventIdsQuery}")
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -113,9 +113,9 @@ export const getNotes: (
|
|||||||
},
|
},
|
||||||
) => Promise<Note[]> = async (db, { filters = {}, limit, contacts, includeIds }) => {
|
) => Promise<Note[]> = async (db, { filters = {}, limit, contacts, includeIds }) => {
|
||||||
let notesQuery = `
|
let notesQuery = `
|
||||||
SELECT
|
SELECT
|
||||||
nostros_notes.*, nostros_users.lnurl, nostros_users.name, nostros_users.picture, nostros_users.contact, nostros_users.created_at as user_created_at FROM nostros_notes
|
nostros_notes.*, nostros_users.lnurl, nostros_users.name, nostros_users.picture, nostros_users.contact, nostros_users.created_at as user_created_at FROM nostros_notes
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
nostros_users ON nostros_users.id = nostros_notes.pubkey
|
nostros_users ON nostros_users.id = nostros_notes.pubkey
|
||||||
`
|
`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user