mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
GODT-1672: implemented bug report feature.
WIP: EventStream grpcClient call now include 'clientPlaftorm' info. Fix: removed unnecessary call to useragent.SetPlatform().
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -95,7 +95,7 @@ service Bridge {
|
||||
rpc ConfigureUserAppleMail(ConfigureAppleMailRequest) returns (google.protobuf.Empty);
|
||||
|
||||
// Server -> Client event stream
|
||||
rpc StartEventStream(google.protobuf.Empty) returns (stream StreamEvent); // Keep streaming until StopEventStream is called.
|
||||
rpc StartEventStream(EventStreamRequest) returns (stream StreamEvent); // Keep streaming until StopEventStream is called.
|
||||
rpc StopEventStream(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
}
|
||||
|
||||
@ -104,10 +104,12 @@ service Bridge {
|
||||
//**********************************************************************************************************************
|
||||
|
||||
message ReportBugRequest {
|
||||
string description = 1;
|
||||
string address = 2;
|
||||
string emailClient = 3;
|
||||
bool includeLogs = 4;
|
||||
string osType = 1;
|
||||
string osVersion = 2;
|
||||
string description = 3;
|
||||
string address = 4;
|
||||
string emailClient = 5;
|
||||
bool includeLogs = 6;
|
||||
|
||||
}
|
||||
|
||||
@ -178,6 +180,11 @@ message ConfigureAppleMailRequest {
|
||||
//**********************************************************************************************************************
|
||||
// Event stream messages
|
||||
//**********************************************************************************************************************
|
||||
|
||||
message EventStreamRequest {
|
||||
string ClientPlatform = 1;
|
||||
}
|
||||
|
||||
message StreamEvent {
|
||||
oneof event {
|
||||
AppEvent app = 1;
|
||||
|
||||
@ -83,7 +83,7 @@ type BridgeClient interface {
|
||||
RemoveUser(ctx context.Context, in *wrapperspb.StringValue, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
ConfigureUserAppleMail(ctx context.Context, in *ConfigureAppleMailRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// Server -> Client event stream
|
||||
StartEventStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (Bridge_StartEventStreamClient, error)
|
||||
StartEventStream(ctx context.Context, in *EventStreamRequest, opts ...grpc.CallOption) (Bridge_StartEventStreamClient, error)
|
||||
StopEventStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
@ -536,7 +536,7 @@ func (c *bridgeClient) ConfigureUserAppleMail(ctx context.Context, in *Configure
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *bridgeClient) StartEventStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (Bridge_StartEventStreamClient, error) {
|
||||
func (c *bridgeClient) StartEventStream(ctx context.Context, in *EventStreamRequest, opts ...grpc.CallOption) (Bridge_StartEventStreamClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &Bridge_ServiceDesc.Streams[0], "/grpc.Bridge/StartEventStream", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -640,7 +640,7 @@ type BridgeServer interface {
|
||||
RemoveUser(context.Context, *wrapperspb.StringValue) (*emptypb.Empty, error)
|
||||
ConfigureUserAppleMail(context.Context, *ConfigureAppleMailRequest) (*emptypb.Empty, error)
|
||||
// Server -> Client event stream
|
||||
StartEventStream(*emptypb.Empty, Bridge_StartEventStreamServer) error
|
||||
StartEventStream(*EventStreamRequest, Bridge_StartEventStreamServer) error
|
||||
StopEventStream(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
|
||||
mustEmbedUnimplementedBridgeServer()
|
||||
}
|
||||
@ -796,7 +796,7 @@ func (UnimplementedBridgeServer) RemoveUser(context.Context, *wrapperspb.StringV
|
||||
func (UnimplementedBridgeServer) ConfigureUserAppleMail(context.Context, *ConfigureAppleMailRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ConfigureUserAppleMail not implemented")
|
||||
}
|
||||
func (UnimplementedBridgeServer) StartEventStream(*emptypb.Empty, Bridge_StartEventStreamServer) error {
|
||||
func (UnimplementedBridgeServer) StartEventStream(*EventStreamRequest, Bridge_StartEventStreamServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StartEventStream not implemented")
|
||||
}
|
||||
func (UnimplementedBridgeServer) StopEventStream(context.Context, *emptypb.Empty) (*emptypb.Empty, error) {
|
||||
@ -1698,7 +1698,7 @@ func _Bridge_ConfigureUserAppleMail_Handler(srv interface{}, ctx context.Context
|
||||
}
|
||||
|
||||
func _Bridge_StartEventStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(emptypb.Empty)
|
||||
m := new(EventStreamRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ package grpc
|
||||
import (
|
||||
cryptotls "crypto/tls"
|
||||
"net"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -112,7 +111,6 @@ func NewService(
|
||||
firstTimeAutostart: sync.Once{},
|
||||
}
|
||||
|
||||
s.userAgent.SetPlatform(runtime.GOOS) // TO-DO GODT-1672 In the previous Qt frontend, this routine used QSysInfo::PrettyProductName to return a more accurate description, e.g. "Windows 10" or "MacOS 10.12"
|
||||
config, err := tls.GetConfig()
|
||||
config.ClientAuth = cryptotls.NoClientCert // skip client auth if the certificate allow it.
|
||||
if err != nil {
|
||||
|
||||
@ -30,6 +30,7 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/v2/pkg/keychain"
|
||||
"github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
|
||||
"github.com/ProtonMail/proton-bridge/v2/pkg/ports"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
@ -218,11 +219,35 @@ func (s *Service) CurrentEmailClient(context.Context, *emptypb.Empty) (*wrappers
|
||||
}
|
||||
|
||||
func (s *Service) ReportBug(_ context.Context, report *ReportBugRequest) (*emptypb.Empty, error) {
|
||||
s.log.WithField("description", report.Description).
|
||||
WithField("address", report.Address).
|
||||
WithField("emailClient", report.EmailClient).
|
||||
WithField("includeLogs", report.IncludeLogs).
|
||||
Info("ReportBug")
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"osType": report.OsType,
|
||||
"osVersion": report.OsVersion,
|
||||
"description": report.Description,
|
||||
"address": report.Address,
|
||||
"emailClient": report.EmailClient,
|
||||
"includeLogs": report.IncludeLogs,
|
||||
}).Info("ReportBug")
|
||||
|
||||
go func() {
|
||||
defer func() { _ = s.SendEvent(NewReportBugFinishedEvent()) }()
|
||||
|
||||
if err := s.bridge.ReportBug(
|
||||
report.OsType,
|
||||
report.OsVersion,
|
||||
report.Description,
|
||||
report.Address,
|
||||
report.Address,
|
||||
report.EmailClient,
|
||||
report.IncludeLogs,
|
||||
); err != nil {
|
||||
s.log.WithError(err).Error("Failed to report bug")
|
||||
_ = s.SendEvent(NewReportBugErrorEvent())
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.SendEvent(NewReportBugSuccessEvent())
|
||||
}()
|
||||
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
|
||||
@ -27,13 +27,15 @@ import (
|
||||
)
|
||||
|
||||
// StartEventStream implement the gRPC server->Client event stream.
|
||||
func (s *Service) StartEventStream(_ *emptypb.Empty, server Bridge_StartEventStreamServer) error {
|
||||
func (s *Service) StartEventStream(request *EventStreamRequest, server Bridge_StartEventStreamServer) error {
|
||||
s.log.Info("Starting Event stream")
|
||||
|
||||
if s.eventStreamCh != nil {
|
||||
return status.Errorf(codes.AlreadyExists, "the service is already streaming") // TO-DO GODT-1667 decide if we want to kill the existing stream.
|
||||
}
|
||||
|
||||
s.userAgent.SetPlatform(request.ClientPlatform)
|
||||
|
||||
s.eventStreamCh = make(chan *StreamEvent)
|
||||
s.eventStreamDoneCh = make(chan struct{})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user