From a89341e1ff7cba3817be398c1ef833c99536a842 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 10 Jul 2024 21:04:00 +0300 Subject: [PATCH] pre-commit: add more rules --- .github/workflows/go.yml | 10 ++++------ .pre-commit-config.yaml | 14 +++++++++++++- pkg/connector/handleslack.go | 12 +++++++++--- pkg/msgconv/msgconv.go | 4 ++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 615216c..9281eff 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,13 +23,11 @@ jobs: - name: Install libolm run: sudo apt-get install libolm-dev libolm3 - - name: Install goimports + - name: Install dependencies run: | go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest export PATH="$HOME/go/bin:$PATH" - - name: Install pre-commit - run: pip install pre-commit - - - name: Lint - run: pre-commit run -a + - name: Run pre-commit + uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e5e43e..266fdb8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace exclude_types: [markdown] @@ -12,4 +12,16 @@ repos: rev: v1.0.0-rc.1 hooks: - id: go-imports-repo + args: + - "-local" + - "go.mau.fi/mautrix-signal" + - "-w" - id: go-vet-repo-mod + - id: go-staticcheck-repo-mod + - id: go-mod-tidy + + - repo: https://github.com/beeper/pre-commit-go + rev: v0.3.1 + hooks: + - id: zerolog-ban-msgf + - id: zerolog-use-stringer diff --git a/pkg/connector/handleslack.go b/pkg/connector/handleslack.go index 67089c7..77158b4 100644 --- a/pkg/connector/handleslack.go +++ b/pkg/connector/handleslack.go @@ -84,7 +84,7 @@ func (s *SlackClient) HandleSlackEvent(rawEvt any) { s.UserLogin.Bridge.QueueRemoteEvent(s.UserLogin, wrapped) } case *slack.EmojiChangedEvent: - //go ut.handleEmojiChange(ctx, evt) + go s.handleEmojiChange(ctx, evt) case *slack.FileSharedEvent, *slack.FilePublicEvent, *slack.FilePrivateEvent, *slack.FileCreatedEvent, *slack.FileChangeEvent, *slack.FileDeletedEvent, *slack.DesktopNotificationEvent, *slack.ReconnectUrlEvent, *slack.LatencyReport: @@ -452,6 +452,12 @@ func (s *SlackMessage) GetTargetMessage() networkid.MessageID { } func (s *SlackMessage) GetChatInfoChange(ctx context.Context) (*bridgev2.ChatInfoChange, error) { - // TODO implement - return &bridgev2.ChatInfoChange{}, nil + fullChatInfo, err := s.Client.fetchChatInfo(ctx, s.Data.Channel, false) + if err != nil { + return nil, fmt.Errorf("failed to get chat info: %w", err) + } + // TODO implement deltas instead of full resync + return &bridgev2.ChatInfoChange{ + ChatInfo: fullChatInfo, + }, nil } diff --git a/pkg/msgconv/msgconv.go b/pkg/msgconv/msgconv.go index 9c0e5b3..9383f1e 100644 --- a/pkg/msgconv/msgconv.go +++ b/pkg/msgconv/msgconv.go @@ -59,9 +59,9 @@ func (mc *MessageConverter) GetMentionedUserInfo(ctx context.Context, userID str if err != nil { zerolog.Ctx(ctx).Err(err).Msg("Failed to get mentioned ghost") } else if ghost != nil { - if ghost.Name == "" { + /*if ghost.Name == "" { // TODO update ghost info - } + }*/ name = ghost.Name mxid = ghost.Intent.GetMXID() }