Skip to content

Commit

Permalink
fix(GODT-3106): Fix broken import route
Browse files Browse the repository at this point in the history
The original fixes to parse the HV error message unfortunately caused
those corrected error routes to start failing when tested against live
proton servers.

Since HV error parsing was improved in a subsequent patch, we no longer
needs the original fix and can therefore revert the changes that are
causing issues.
  • Loading branch information
LBeernaertProton committed Nov 6, 2023
1 parent 77833c9 commit 5f248df
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions contact_types.go
Expand Up @@ -278,8 +278,8 @@ type CreateContactsReq struct {
}

type CreateContactResp struct {
Response APIError
Contact Contact
APIError
Contact Contact
}

type CreateContactsRes struct {
Expand Down
2 changes: 1 addition & 1 deletion helper_test.go
Expand Up @@ -53,6 +53,6 @@ func createTestMessages(t *testing.T, c *proton.Client, pass string, count int)
require.NoError(t, err)

for _, res := range res {
require.Equal(t, proton.SuccessCode, res.Response.Code)
require.Equal(t, proton.SuccessCode, res.Code)
}
}
4 changes: 2 additions & 2 deletions manager_report_types.go
Expand Up @@ -57,8 +57,8 @@ type ReportBugAttachmentReq struct {
}

type ReportBugRes struct {
Response APIError
Token *string
APIError
Token *string
}

func (req ReportBugReq) toFormData() map[string]string {
Expand Down
4 changes: 2 additions & 2 deletions message_import.go
Expand Up @@ -58,8 +58,8 @@ func (c *Client) ImportMessages(ctx context.Context, addrKR *crypto.KeyRing, wor
}

for _, res := range res {
if res.Response.Code != SuccessCode {
return nil, fmt.Errorf("failed to import message: %w", res.Response)
if res.Code != SuccessCode {
return nil, fmt.Errorf("failed to import message: %w", res)
}
}

Expand Down
2 changes: 1 addition & 1 deletion message_import_types.go
Expand Up @@ -26,7 +26,7 @@ type ImportMetadata struct {
}

type ImportRes struct {
Response APIError
APIError
MessageID string
}

Expand Down
8 changes: 4 additions & 4 deletions server/contacts.go
Expand Up @@ -71,7 +71,7 @@ func (s *Server) handlePostContacts() gin.HandlerFunc {
proton.CreateContactsRes{
Index: i,
Response: proton.CreateContactResp{
Response: proton.APIError{Code: proton.InvalidValue, Message: err.Error()},
APIError: proton.APIError{Code: proton.InvalidValue, Message: err.Error()},
},
})
continue
Expand All @@ -83,7 +83,7 @@ func (s *Server) handlePostContacts() gin.HandlerFunc {
proton.CreateContactsRes{
Index: i,
Response: proton.CreateContactResp{
Response: proton.APIError{Code: proton.InvalidValue, Message: err.Error()},
APIError: proton.APIError{Code: proton.InvalidValue, Message: err.Error()},
},
})
continue
Expand All @@ -94,7 +94,7 @@ func (s *Server) handlePostContacts() gin.HandlerFunc {
proton.CreateContactsRes{
Index: i,
Response: proton.CreateContactResp{
Response: proton.APIError{Code: proton.InvalidValue, Message: err.Error()},
APIError: proton.APIError{Code: proton.InvalidValue, Message: err.Error()},
},
})
continue
Expand All @@ -103,7 +103,7 @@ func (s *Server) handlePostContacts() gin.HandlerFunc {
proton.CreateContactsRes{
Index: i,
Response: proton.CreateContactResp{
Response: proton.APIError{Code: proton.SuccessCode},
APIError: proton.APIError{Code: proton.SuccessCode},
Contact: contact,
},
})
Expand Down
4 changes: 2 additions & 2 deletions server/messages.go
Expand Up @@ -297,14 +297,14 @@ func (s *Server) handlePutMailMessagesImport() gin.HandlerFunc {
)
if err != nil {
res.Response = proton.ImportRes{
Response: proton.APIError{
APIError: proton.APIError{
Code: proton.InvalidValue,
Message: fmt.Sprintf("failed to import: %v", err),
},
}
} else {
res.Response = proton.ImportRes{
Response: proton.APIError{Code: proton.SuccessCode},
APIError: proton.APIError{Code: proton.SuccessCode},
MessageID: messageID,
}
}
Expand Down
8 changes: 4 additions & 4 deletions server/server_test.go
Expand Up @@ -1002,7 +1002,7 @@ func TestServer_Import(t *testing.T) {
res := importMessages(ctx, t, c, addr[0].ID, addrKRs[addr[0].ID], []string{}, proton.MessageFlagReceived, 1)
require.NoError(t, err)
require.Len(t, res, 1)
require.Equal(t, proton.SuccessCode, res[0].Response.Code)
require.Equal(t, proton.SuccessCode, res[0].Code)

message, err := c.GetMessage(ctx, res[0].MessageID)
require.NoError(t, err)
Expand Down Expand Up @@ -1052,7 +1052,7 @@ func TestServer_Import_Dedup(t *testing.T) {
)
require.NoError(t, err)
require.Len(t, res, 1)
require.Equal(t, proton.SuccessCode, res[0].Response.Code)
require.Equal(t, proton.SuccessCode, res[0].Code)

message, err := c.GetMessage(ctx, res[0].MessageID)
require.NoError(t, err)
Expand All @@ -1075,7 +1075,7 @@ func TestServer_Import_Dedup(t *testing.T) {
)
require.NoError(t, err)
require.Len(t, resDedup, 1)
require.Equal(t, proton.SuccessCode, resDedup[0].Response.Code)
require.Equal(t, proton.SuccessCode, resDedup[0].Code)
require.Equal(t, res[0].MessageID, resDedup[0].MessageID)
})
}, WithMessageDedup())
Expand Down Expand Up @@ -1444,7 +1444,7 @@ func TestServer_Import_FlagsAndLabels(t *testing.T) {
require.Error(t, err)
} else {
require.NoError(t, err)
require.Equal(t, proton.SuccessCode, res[0].Response.Code)
require.Equal(t, proton.SuccessCode, res[0].Code)

message, err := c.GetMessage(ctx, res[0].MessageID)
require.NoError(t, err)
Expand Down

0 comments on commit 5f248df

Please sign in to comment.