feat: child webview
This commit is contained in:
483
src-tauri/Cargo.lock
generated
483
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -11,12 +11,12 @@ rust-version = "1.68"
|
||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
||||
|
||||
[dependencies]
|
||||
nostr-sdk = { version = "0.28", features = ["sqlite"] }
|
||||
nostr-sdk = { version = "0.29", features = ["sqlite"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "2.0.0-beta", features = [
|
||||
"unstable",
|
||||
"unstable",
|
||||
"tray-icon",
|
||||
"macos-private-api",
|
||||
"native-tls-vendored",
|
||||
|
||||
@@ -30,11 +30,14 @@
|
||||
"updater:allow-check",
|
||||
"updater:default",
|
||||
"window:allow-start-dragging",
|
||||
"window:allow-create",
|
||||
"store:allow-get",
|
||||
"clipboard-manager:allow-write",
|
||||
"clipboard-manager:allow-read",
|
||||
"webview:allow-create-webview-window",
|
||||
"webview:allow-create-webview",
|
||||
"webview:allow-set-webview-size",
|
||||
"webview:allow-set-webview-position",
|
||||
"dialog:allow-open",
|
||||
"fs:allow-read-file",
|
||||
"shell:allow-open",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","editor","settings","nwc","zap-*","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}
|
||||
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","editor","settings","nwc","zap-*","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","window:allow-create","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","webview:allow-set-webview-size","webview:allow-set-webview-position","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}
|
||||
@@ -11,6 +11,13 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "A list of capabilities.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Capability"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A list of capabilities.",
|
||||
"type": "object",
|
||||
@@ -34,8 +41,7 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier",
|
||||
"permissions",
|
||||
"windows"
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
@@ -86,14 +92,10 @@
|
||||
},
|
||||
"platforms": {
|
||||
"description": "Target platforms this capability applies. By default all platforms are affected by this capability.",
|
||||
"default": [
|
||||
"linux",
|
||||
"macOS",
|
||||
"windows",
|
||||
"android",
|
||||
"iOS"
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Target"
|
||||
}
|
||||
@@ -108,7 +110,7 @@
|
||||
],
|
||||
"properties": {
|
||||
"urls": {
|
||||
"description": "Remote domains this capability refers to. Can use glob patterns.",
|
||||
"description": "Remote domains this capability refers to using the [URLPattern standard](https://urlpattern.spec.whatwg.org/).\n\n# Examples\n\n- \"https://*.mydomain.dev\": allows subdomains of mydomain.dev - \"https://mydomain.dev/api/*\": allows any subpath of mydomain.dev/api",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -2236,32 +2238,48 @@
|
||||
"items": {
|
||||
"title": "ScopeEntry",
|
||||
"description": "HTTP scope entry object definition.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"items": {
|
||||
"title": "ScopeEntry",
|
||||
"description": "HTTP scope entry object definition.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4762,6 +4780,97 @@
|
||||
"http:deny-fetch-send"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:default"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-from-bytes -> Enables the from_bytes command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-from-bytes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-from-path -> Enables the from_path command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-from-path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-height -> Enables the height command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-height"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-new -> Enables the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-rgba -> Enables the rgba command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-rgba"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-width -> Enables the width command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-width"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-from-bytes -> Denies the from_bytes command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-from-bytes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-from-path -> Denies the from_path command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-from-path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-height -> Denies the height command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-height"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-new -> Denies the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-rgba -> Denies the rgba command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-rgba"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-width -> Denies the width command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-width"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "menu:default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "A list of capabilities.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Capability"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A list of capabilities.",
|
||||
"type": "object",
|
||||
@@ -34,8 +41,7 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier",
|
||||
"permissions",
|
||||
"windows"
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
@@ -86,14 +92,10 @@
|
||||
},
|
||||
"platforms": {
|
||||
"description": "Target platforms this capability applies. By default all platforms are affected by this capability.",
|
||||
"default": [
|
||||
"linux",
|
||||
"macOS",
|
||||
"windows",
|
||||
"android",
|
||||
"iOS"
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Target"
|
||||
}
|
||||
@@ -108,7 +110,7 @@
|
||||
],
|
||||
"properties": {
|
||||
"urls": {
|
||||
"description": "Remote domains this capability refers to. Can use glob patterns.",
|
||||
"description": "Remote domains this capability refers to using the [URLPattern standard](https://urlpattern.spec.whatwg.org/).\n\n# Examples\n\n- \"https://*.mydomain.dev\": allows subdomains of mydomain.dev - \"https://mydomain.dev/api/*\": allows any subpath of mydomain.dev/api",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -2236,32 +2238,48 @@
|
||||
"items": {
|
||||
"title": "ScopeEntry",
|
||||
"description": "HTTP scope entry object definition.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"items": {
|
||||
"title": "ScopeEntry",
|
||||
"description": "HTTP scope entry object definition.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4762,6 +4780,97 @@
|
||||
"http:deny-fetch-send"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:default"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-from-bytes -> Enables the from_bytes command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-from-bytes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-from-path -> Enables the from_path command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-from-path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-height -> Enables the height command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-height"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-new -> Enables the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-rgba -> Enables the rgba command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-rgba"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:allow-width -> Enables the width command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:allow-width"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-from-bytes -> Denies the from_bytes command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-from-bytes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-from-path -> Denies the from_path command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-from-path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-height -> Denies the height command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-height"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-new -> Denies the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-rgba -> Denies the rgba command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-rgba"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "image:deny-width -> Denies the width command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image:deny-width"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "menu:default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
|
||||
@@ -171,43 +171,37 @@ pub async fn publish(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn repost(id: &str, pubkey: &str, state: State<'_, Nostr>) -> Result<EventId, ()> {
|
||||
pub async fn repost(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
|
||||
let client = &state.client;
|
||||
let public_key = PublicKey::from_str(pubkey).unwrap();
|
||||
let event_id = EventId::from_hex(id).unwrap();
|
||||
let event = Event::from_json(raw).unwrap();
|
||||
|
||||
let event = client
|
||||
.repost_event(event_id, public_key)
|
||||
.await
|
||||
.expect("Repost failed");
|
||||
|
||||
Ok(event)
|
||||
if let Ok(event_id) = client.repost(&event, None).await {
|
||||
Ok(event_id)
|
||||
} else {
|
||||
Err("Repost failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn upvote(id: &str, pubkey: &str, state: State<'_, Nostr>) -> Result<EventId, ()> {
|
||||
pub async fn upvote(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
|
||||
let client = &state.client;
|
||||
let public_key = PublicKey::from_str(pubkey).unwrap();
|
||||
let event_id = EventId::from_hex(id).unwrap();
|
||||
let event = Event::from_json(raw).unwrap();
|
||||
|
||||
let event = client
|
||||
.like(event_id, public_key)
|
||||
.await
|
||||
.expect("Upvote failed");
|
||||
|
||||
Ok(event)
|
||||
if let Ok(event_id) = client.like(&event).await {
|
||||
Ok(event_id)
|
||||
} else {
|
||||
Err("Upvote failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn downvote(id: &str, pubkey: &str, state: State<'_, Nostr>) -> Result<EventId, ()> {
|
||||
pub async fn downvote(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
|
||||
let client = &state.client;
|
||||
let public_key = PublicKey::from_str(pubkey).unwrap();
|
||||
let event_id = EventId::from_hex(id).unwrap();
|
||||
let event = Event::from_json(raw).unwrap();
|
||||
|
||||
let event = client
|
||||
.dislike(event_id, public_key)
|
||||
.await
|
||||
.expect("Downvote failed");
|
||||
|
||||
Ok(event)
|
||||
if let Ok(event_id) = client.dislike(&event).await {
|
||||
Ok(event_id)
|
||||
} else {
|
||||
Err("Downvote failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ pub fn event_to_bech32(id: &str, relays: Vec<String>) -> Result<String, ()> {
|
||||
#[tauri::command]
|
||||
pub fn user_to_bech32(key: &str, relays: Vec<String>) -> Result<String, ()> {
|
||||
let pubkey = PublicKey::from_str(key).unwrap();
|
||||
let profile = Nip19Profile::new(pubkey, relays);
|
||||
let profile = Nip19Profile::new(pubkey, relays).unwrap();
|
||||
|
||||
Ok(profile.to_bech32().unwrap())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user