Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(teamhub): name an Outlook account by Microsoft's own fields
shoudi zhengb109132093e1
diff --git a/apps/teamhub/internal/composio/mail_import.go b/apps/teamhub/internal/composio/mail_import.goindex 3e671a24..9f23aec9 100644--- a/apps/teamhub/internal/composio/mail_import.go+++ b/apps/teamhub/internal/composio/mail_import.go@@ -379,10 +379,11 @@ type OutlookIdentity struct {ID, Label string}-// IdentifyOutlook returns the signed-in mailbox. The label is display only:-// Graph leaves mail empty for a personal account signed in with another-// provider's address, whose userPrincipalName is that sign-in address, so the-// sender of the newest Sent Items message names the mailbox before it.+// IdentifyOutlook returns the Microsoft account. The label is display only and+// is what Microsoft names the account: its primary mail, or for a personal+// account without one the sign-in name, which may be another provider's+// address. A personal account owns several addresses, so none is inferred+// from mail; mail direction comes from folders, never from this label.func (c *Client) IdentifyOutlook(ctx context.Context, accountID string) (OutlookIdentity, error) {var wire struct {ID string `json:"id"`@@ -393,14 +394,6 @@ func (c *Client) IdentifyOutlook(ctx context.Context, accountID string) (Outlookreturn OutlookIdentity{}, err}label := wire.Mail- if label == "" {- // A failed read fails identification rather than falling back, so a- // throttled check keeps the stored label instead of the sign-in address.- var err error- if label, err = c.outlookSentAddress(ctx, accountID); err != nil {- return OutlookIdentity{}, err- }- }if label == "" {label = wire.Principal}@@ -409,24 +402,3 @@ func (c *Client) IdentifyOutlook(ctx context.Context, accountID string) (Outlook}return OutlookIdentity{wire.ID, label}, nil}--// outlookSentAddress returns the sender of the newest Sent Items message, or-// "" when Sent Items is empty.-func (c *Client) outlookSentAddress(ctx context.Context, accountID string) (string, error) {- var wire struct {- Value []struct {- From outlookRecipient `json:"from"`- } `json:"value"`- }- if err := c.proxy(ctx, proxyRequest{ConnectedAccountID: accountID, Endpoint: "/v1.0/me/mailFolders/sentitems/messages", Method: http.MethodGet, Parameters: []proxyParameter{- {Name: "$top", Value: "1", Type: "query"},- {Name: "$orderby", Value: "sentDateTime desc", Type: "query"},- {Name: "$select", Value: "from", Type: "query"},- }}, &wire, "read Outlook sent mailbox address"); err != nil {- return "", err- }- if len(wire.Value) == 0 {- return "", nil- }- return strings.TrimSpace(wire.Value[0].From.EmailAddress.Address), nil-}diff --git a/apps/teamhub/internal/composio/mail_import_test.go b/apps/teamhub/internal/composio/mail_import_test.goindex 294c7bf0..090d04dc 100644--- a/apps/teamhub/internal/composio/mail_import_test.go+++ b/apps/teamhub/internal/composio/mail_import_test.go@@ -395,16 +395,9 @@ func TestOutlookMailImportRejectsCursorWithoutSentFolder(t *testing.T) {}func TestIdentifyOutlookLabel(t *testing.T) {- for _, test := range []struct {- name, mail string- sent any- want string- fails bool- }{- {"mail", "[email protected]", map[string]any{"value": []any{map[string]any{"from": map[string]any{"emailAddress": map[string]string{"address": "[email protected]"}}}}}, "[email protected]", false},- {"sent items sender", "", map[string]any{"value": []any{map[string]any{"from": map[string]any{"emailAddress": map[string]string{"address": "[email protected]"}}}}}, "[email protected]", false},- {"empty sent items", "", map[string]any{"value": []any{}}, "[email protected]", false},- {"sent items error", "", nil, "", true},+ for _, test := range []struct{ name, mail, want string }{+ {"primary mail", "[email protected]", "[email protected]"},+ {"sign-in name without mail", "", "[email protected]"},} {t.Run(test.name, func(t *testing.T) {server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {@@ -413,18 +406,11 @@ func TestIdentifyOutlookLabel(t *testing.T) {t.Error(err)return}- switch request.Endpoint {- case "https://graph.microsoft.com/v1.0/me":- _ = json.NewEncoder(w).Encode(map[string]any{"status": 200, "data": map[string]string{"id": "graph-id", "mail": test.mail, "userPrincipalName": "[email protected]"}})- case "/v1.0/me/mailFolders/sentitems/messages":- if test.sent == nil {- w.WriteHeader(http.StatusInternalServerError)- return- }- _ = json.NewEncoder(w).Encode(map[string]any{"status": 200, "data": test.sent})- default:+ if request.Endpoint != "https://graph.microsoft.com/v1.0/me" {t.Errorf("unexpected endpoint %s", request.Endpoint)+ return}+ _ = json.NewEncoder(w).Encode(map[string]any{"status": 200, "data": map[string]string{"id": "graph-id", "mail": test.mail, "userPrincipalName": "[email protected]"}})}))defer server.Close()client, err := New(Config{APIKey: "test", EnvironmentKey: "test", BaseURL: server.URL, HTTPClient: server.Client()})@@ -435,12 +421,6 @@ func TestIdentifyOutlookLabel(t *testing.T) {return ConnectionBinding{}, nil})identity, err := client.IdentifyOutlook(context.Background(), "account")- if test.fails {- if err == nil {- t.Fatalf("identity=%+v, want the Sent Items error", identity)- }- return- }if err != nil {t.Fatal(err)}