@@ -15,8 +15,13 @@ type ClipboardServer struct {
15
15
16
16
// ClipboardRead is used by plugins to get the value of an entry
17
17
func (m * ClipboardServer ) ClipboardRead (ctx context.Context , req * proto.ClipboardReadRequest ) (* proto.ClipboardReadResponse , error ) {
18
+ session , err := NewSessionFromProto (req .Session )
19
+ if err != nil {
20
+ return nil , err
21
+ }
22
+
18
23
value , err := m .Impl .Read (
19
- context .WithValue (ctx , Session {}, NewSessionFromProto ( req . Session ) ),
24
+ context .WithValue (ctx , Session {}, session ),
20
25
)
21
26
if err != nil {
22
27
return nil , err
@@ -29,6 +34,11 @@ func (m *ClipboardServer) ClipboardRead(ctx context.Context, req *proto.Clipboar
29
34
30
35
// ClipboardReadStream is used by plugins to get the value of an entry
31
36
func (m * ClipboardServer ) ClipboardReadStream (req * proto.ClipboardReadStreamRequest , stream proto.Clipboard_ClipboardReadStreamServer ) error {
37
+ session , err := NewSessionFromProto (req .Session )
38
+ if err != nil {
39
+ return err
40
+ }
41
+
32
42
handler := func (text string , err error ) {
33
43
var errText string
34
44
if err != nil {
@@ -45,7 +55,7 @@ func (m *ClipboardServer) ClipboardReadStream(req *proto.ClipboardReadStreamRequ
45
55
46
56
go func () {
47
57
err := m .Impl .Listen (
48
- context .WithValue (stream .Context (), Session {}, NewSessionFromProto ( req . Session ) ),
58
+ context .WithValue (stream .Context (), Session {}, session ),
49
59
handler ,
50
60
)
51
61
// TODO: move this to a real logger once we move this into sidekick
@@ -62,8 +72,13 @@ func (m *ClipboardServer) ClipboardReadStream(req *proto.ClipboardReadStreamRequ
62
72
63
73
// ClipboardWrite is used by plugins to set an entry
64
74
func (m * ClipboardServer ) ClipboardWrite (ctx context.Context , req * proto.ClipboardWriteRequest ) (* emptypb.Empty , error ) {
65
- err := m .Impl .Write (
66
- context .WithValue (ctx , Session {}, NewSessionFromProto (req .Session )),
75
+ session , err := NewSessionFromProto (req .Session )
76
+ if err != nil {
77
+ return nil , err
78
+ }
79
+
80
+ err = m .Impl .Write (
81
+ context .WithValue (ctx , Session {}, session ),
67
82
req .Text ,
68
83
)
69
84
if err != nil {
0 commit comments