support nip94 and fix some bugs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { FetchOptions, ResponseType, fetch } from '@tauri-apps/plugin-http';
|
||||
import { fetch } from '@tauri-apps/plugin-http';
|
||||
import * as cheerio from 'cheerio';
|
||||
|
||||
import { OPENGRAPH } from '@stores/constants';
|
||||
@@ -332,10 +332,9 @@ function parseResponse(response: IPreFetchedResource, options?: ILinkPreviewOpti
|
||||
|
||||
export async function getLinkPreview(text: string) {
|
||||
const fetchUrl = text;
|
||||
const options: FetchOptions = {
|
||||
const options = {
|
||||
method: 'GET',
|
||||
timeout: 5,
|
||||
responseType: ResponseType.Text,
|
||||
};
|
||||
|
||||
let response = await fetch(fetchUrl, options);
|
||||
|
||||
@@ -529,10 +529,15 @@ export async function getRelays() {
|
||||
export async function getExplicitRelayUrls() {
|
||||
const db = await connect();
|
||||
const activeAccount = await getActiveAccount();
|
||||
|
||||
if (!activeAccount) return null;
|
||||
|
||||
const result: Relays[] = await db.select(
|
||||
`SELECT * FROM relays WHERE account_id = "${activeAccount.id}";`
|
||||
);
|
||||
|
||||
if (result.length > 0) return result.map((el) => el.relay);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -541,7 +546,7 @@ export async function createRelay(relay: string, purpose?: string) {
|
||||
const db = await connect();
|
||||
const activeAccount = await getActiveAccount();
|
||||
return await db.execute(
|
||||
'INSERT OR IGNORE INTO blocks (account_id, relay, purpose) VALUES (?, ?, ?);',
|
||||
'INSERT OR IGNORE INTO relays (account_id, relay, purpose) VALUES (?, ?, ?);',
|
||||
[activeAccount.id, relay, purpose || '']
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user