Load user data before updating, prefer newer events in repository over old ones with the same created_at, add list update utils
This commit is contained in:
@@ -39,13 +39,13 @@ export class Encryptable<T extends EventTemplate> {
|
||||
*/
|
||||
async reconcile(encrypt: Encrypt) {
|
||||
const encryptContent = () => {
|
||||
if (!this.updates.content) return null
|
||||
if (!this.updates.content) return undefined
|
||||
|
||||
return encrypt(this.updates.content)
|
||||
}
|
||||
|
||||
const encryptTags = () => {
|
||||
if (!this.updates.tags) return null
|
||||
if (!this.updates.tags) return undefined
|
||||
|
||||
return Promise.all(
|
||||
this.updates.tags.map(async tag => {
|
||||
|
||||
@@ -89,6 +89,25 @@ export const addToListPrivately = (list: List, ...tags: string[][]) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const updateList = (
|
||||
list: List,
|
||||
{publicTags, privateTags}: {publicTags?: string[][]; privateTags?: string[][]},
|
||||
) => {
|
||||
const template = {
|
||||
kind: list.kind,
|
||||
content: list.event?.content || "",
|
||||
tags: publicTags || list.publicTags,
|
||||
}
|
||||
|
||||
const updates: EncryptableUpdates = {}
|
||||
|
||||
if (privateTags) {
|
||||
updates.content = JSON.stringify(privateTags)
|
||||
}
|
||||
|
||||
return new Encryptable(template, updates)
|
||||
}
|
||||
|
||||
export const getRelaysFromList = (list?: List, mode?: RelayMode): string[] => {
|
||||
let tags = getRelayTags(getListTags(list))
|
||||
|
||||
|
||||
@@ -119,4 +119,6 @@ export const uniqTags = (tags: string[][]) => uniqBy(t => t.slice(0, 2).join(":"
|
||||
|
||||
export const tagsFromIMeta = (imeta: string[]) => imeta.map((m: string) => m.split(" "))
|
||||
|
||||
export const tagger = (name: string) => (value: string) => [name, value]
|
||||
export const tagger =
|
||||
(name: string) =>
|
||||
(value: string, ...args: unknown[]) => [name, value]
|
||||
|
||||
Reference in New Issue
Block a user