Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

fix(core): handle send-file notification clicks on Windows

baiyuze8e39732dc952
diff --git a/client-core/cmd/pasteferryd/notification_action.go b/client-core/cmd/pasteferryd/notification_action.go
index c45b1eb..a6e9ad4 100644
--- a/client-core/cmd/pasteferryd/notification_action.go
+++ b/client-core/cmd/pasteferryd/notification_action.go
@@ -24,10 +24,16 @@ func activateNotification(raw string) error {
return fmt.Errorf("invalid notification URI")
}
verb, id := u.Query().Get("action"), u.Query().Get("clip")
- if verb == "open" {
+ // 复制记录的「打开」只要把主窗口拉起来;隔空传送的「打开」要切到隔空传送页,由后台服务转告界面
+ if verb == "open" && !notifications.IsTransfer(id) {
return notifications.OpenUI()
}
- if (verb != "receive" && verb != "apply") || id == "" {
+ switch {
+ case id == "":
+ return fmt.Errorf("invalid notification action")
+ case notifications.IsTransfer(id) && (verb == "open" || verb == "reveal"):
+ case verb == "receive" || verb == "apply":
+ default:
return fmt.Errorf("invalid notification action")
}
paths, err := config.DefaultPaths()
diff --git a/client-core/internal/notifications/notifications.go b/client-core/internal/notifications/notifications.go
index 8987cdf..eb5f82c 100644
--- a/client-core/internal/notifications/notifications.go
+++ b/client-core/internal/notifications/notifications.go
@@ -158,6 +158,10 @@ func (m *Manager) Completed(r *pb.ClipRecord, result *pb.ClipboardWriteResult) {
// 隔空传送通知的 ID 前缀,与复制记录的通知区分开
const transferPrefix = "transfer-"
+// IsTransfer 判断通知是不是隔空传送的:它的「打开」要切到隔空传送页,还有「在文件夹中显示」,
+// 都要交给后台服务处理,不能只是把主窗口拉起来。
+func IsTransfer(id string) bool { return strings.HasPrefix(id, transferPrefix) }
+
// Transfer 发一条隔空传送的通知:kind 是 incoming(较大的传输开始了)、received、failed。
// 同一批的通知用同一个 ID,后一条替换前一条。folder 是保存位置在通知里的叫法。
func (m *Manager) Transfer(kind string, t *pb.Transfer, folder string) {