-
Notifications
You must be signed in to change notification settings - Fork 371
fix: ... (spread vs. rest property) variable assignment
#366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
414e003
f3a5574
c443959
b6b93b7
6d0a2da
9b90066
e07b1ed
3409a3e
629ce0c
14c3289
ec9aba6
b83e79a
749429c
d71599c
60802a4
bfbbd05
ddf04ef
ef45841
2887e3a
8fb9b9b
2e30352
0f2d29b
199b267
9a94e00
4ef9d98
0776114
1a38165
52a4eab
d78558e
6121294
fe500ff
40e9a27
29527b7
9e6296f
05c9931
af4f8a8
baa28d5
ea5f3fa
3283c55
4a698bd
85b0ac4
925eef2
1d571d6
b7b8651
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,14 +57,15 @@ export async function createObject<Type extends APObject>( | |
| .bind(apId, type, JSON.stringify(sanitizedProperties), originalActorId.toString(), local ? 1 : 0, uuid) | ||
| .first() | ||
|
|
||
| // prettier-ignore | ||
| return { | ||
| ...sanitizedProperties, | ||
| type, | ||
| id: new URL(row.id), | ||
| published: new Date(row.cdate).toISOString(), | ||
|
|
||
| [mastodonIdSymbol]: row.mastodon_id, | ||
| [originalActorIdSymbol]: row.original_actor_id, | ||
| ...sanitizedProperties | ||
| } as Type | ||
| } | ||
|
|
||
|
|
@@ -129,16 +130,19 @@ export async function cacheObject( | |
|
|
||
| { | ||
| const properties = JSON.parse(row.properties) | ||
|
|
||
| // prettier-ignore | ||
| const object = { | ||
| published: new Date(row.cdate).toISOString(), | ||
| ...properties, | ||
|
|
||
| type: row.type, | ||
| id: new URL(row.id), | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unnecessary to set |
||
| [mastodonIdSymbol]: row.mastodon_id, | ||
| [originalActorIdSymbol]: row.original_actor_id, | ||
| [originalObjectIdSymbol]: row.original_object_id, | ||
|
|
||
| ...properties | ||
| } as APObject | ||
|
|
||
| return { object, created: true } | ||
|
|
@@ -208,16 +212,17 @@ export async function getObjectBy(db: Database, key: ObjectByKey, value: string) | |
| const result: any = results[0] | ||
| const properties = JSON.parse(result.properties) | ||
|
|
||
| // prettier-ignore | ||
| return { | ||
| published: new Date(result.cdate).toISOString(), | ||
| ...properties, | ||
|
|
||
| type: result.type, | ||
| id: new URL(result.id), | ||
|
|
||
| [mastodonIdSymbol]: result.mastodon_id, | ||
| [originalActorIdSymbol]: result.original_actor_id, | ||
| [originalObjectIdSymbol]: result.original_object_id, | ||
| ...properties | ||
| } as APObject | ||
| } | ||
|
|
||
|
|
@@ -231,9 +236,12 @@ export async function sanitizeObjectProperties(properties: unknown): Promise<APO | |
| if (!isAPObject(properties)) { | ||
| throw new Error('Invalid object properties. Expected an object but got ' + JSON.stringify(properties)) | ||
| } | ||
|
|
||
| // prettier-ignore | ||
| const sanitized: APObject = { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: Manually setting the type to |
||
| ...properties, | ||
| ...properties | ||
| } | ||
|
|
||
| if ('content' in properties) { | ||
| sanitized.content = await sanitizeContent(properties.content as string) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unnecessary to set
const properties = JSON.parse(row.properties)becauserow.properties === sanitizedProperties