Fixed posts not saving correctly after DB migration
This commit is contained in:
parent
8d3a23ee88
commit
4e7196182c
@ -24,5 +24,4 @@ export interface Account {
|
|||||||
display_name: string;
|
display_name: string;
|
||||||
url: string;
|
url: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
avatar_static: string;
|
|
||||||
}
|
}
|
||||||
|
@ -201,24 +201,22 @@ export async function savePost(post: Post): Promise<undefined> {
|
|||||||
const account = post.account;
|
const account = post.account;
|
||||||
db.run(
|
db.run(
|
||||||
`
|
`
|
||||||
INSERT INTO accounts (id, acct, username, display_name, url, avatar, avatar_static)
|
INSERT INTO accounts (id, acct, username, display_name, url, avatar)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?, ?)
|
||||||
ON CONFLICT(id)
|
ON CONFLICT(url)
|
||||||
DO UPDATE SET
|
DO UPDATE SET
|
||||||
acct=excluded.acct,
|
acct=excluded.acct,
|
||||||
username=excluded.username,
|
username=excluded.username,
|
||||||
display_name=excluded.display_name,
|
display_name=excluded.display_name,
|
||||||
url=excluded.url,
|
id=excluded.id,
|
||||||
avatar=excluded.avatar,
|
avatar=excluded.avatar;`,
|
||||||
avatar_static=excluded.avatar_static;`,
|
|
||||||
[
|
[
|
||||||
account.id,
|
account.id,
|
||||||
account.acct,
|
account.acct,
|
||||||
account.username,
|
account.username,
|
||||||
account.display_name,
|
account.display_name,
|
||||||
account.url,
|
account.url,
|
||||||
account.avatar,
|
account.avatar
|
||||||
account.avatar_static
|
|
||||||
],
|
],
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err !== null) {
|
if (err !== null) {
|
||||||
@ -229,12 +227,12 @@ export async function savePost(post: Post): Promise<undefined> {
|
|||||||
db.run(
|
db.run(
|
||||||
`
|
`
|
||||||
INSERT INTO posts (id, content, created_at, url, account_id)
|
INSERT INTO posts (id, content, created_at, url, account_id)
|
||||||
VALUES (?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET
|
VALUES (?, ?, ?, ?, ?) ON CONFLICT(url) DO UPDATE SET
|
||||||
content=excluded.content,
|
content=excluded.content,
|
||||||
created_at=excluded.created_at,
|
created_at=excluded.created_at,
|
||||||
url=excluded.url,
|
id=excluded.id,
|
||||||
account_id=excluded.account_id;`,
|
account_id=excluded.account_id;`,
|
||||||
[post.id, post.content, post.created_at, post.url, post.account.id],
|
[post.id, post.content, post.created_at, post.url, post.account.url],
|
||||||
(postErr) => {
|
(postErr) => {
|
||||||
if (postErr !== null) {
|
if (postErr !== null) {
|
||||||
console.error(`Could not insert post ${post.url}`, postErr);
|
console.error(`Could not insert post ${post.url}`, postErr);
|
||||||
@ -259,7 +257,7 @@ export async function savePost(post: Post): Promise<undefined> {
|
|||||||
}
|
}
|
||||||
db.run(
|
db.run(
|
||||||
'INSERT INTO poststags (post_id, tag_url) VALUES (?, ?)',
|
'INSERT INTO poststags (post_id, tag_url) VALUES (?, ?)',
|
||||||
[post.id, tag.url],
|
[post.url, tag.url],
|
||||||
(posttagserr) => {
|
(posttagserr) => {
|
||||||
if (posttagserr !== null) {
|
if (posttagserr !== null) {
|
||||||
console.error(
|
console.error(
|
||||||
@ -369,8 +367,7 @@ export async function getPosts(since: string | null, before: string | null, limi
|
|||||||
username: row.username,
|
username: row.username,
|
||||||
display_name: row.display_name,
|
display_name: row.display_name,
|
||||||
url: row.account_url,
|
url: row.account_url,
|
||||||
avatar: row.avatar,
|
avatar: row.avatar
|
||||||
avatar_static: ''
|
|
||||||
} as Account
|
} as Account
|
||||||
} as Post;
|
} as Post;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user