-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,329 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ logs/ | |
!example-config.yaml | ||
!.pre-commit-config.yaml | ||
/start | ||
/pkg/mautrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }' | head -n1) | ||
GO_LDFLAGS="-s -w -X main.Tag=$(git describe --exact-match --tags 2>/dev/null) -X main.Commit=$(git rev-parse HEAD) -X 'main.BuildTime=`date -Iseconds`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'" | ||
go build -ldflags="$GO_LDFLAGS" ./cmd/mautrix-twitter "$@" | ||
go build -ldflags="$GO_LDFLAGS" ./cmd/mautrix-twitter "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// mautrix-twitter - A Matrix-Slack puppeting bridge. | ||
// mautrix-twitter - A Matrix-Twitter puppeting bridge. | ||
// Copyright (C) 2024 Tulir Asokan | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
|
@@ -16,5 +16,27 @@ | |
|
||
package main | ||
|
||
import ( | ||
"go.mau.fi/mautrix-twitter/pkg/connector" | ||
Check failure on line 20 in cmd/mautrix-twitter/main.go GitHub Actions / Lint (latest)
Check failure on line 20 in cmd/mautrix-twitter/main.go GitHub Actions / Lint (latest)
|
||
"maunium.net/go/mautrix/bridgev2/matrix/mxmain" | ||
) | ||
|
||
// Information to find out exactly which commit the bridge was built from. | ||
// These are filled at build time with the -X linker flag. | ||
var ( | ||
Tag = "unknown" | ||
Commit = "unknown" | ||
BuildTime = "unknown" | ||
) | ||
|
||
func main() { | ||
m := mxmain.BridgeMain{ | ||
Name: "mautrix-twitter", | ||
URL: "https://github.com/mautrix/twitter", | ||
Description: "A Matrix-Twitter puppeting bridge.", | ||
Version: "0.16.0", | ||
Connector: connector.NewConnector(), | ||
} | ||
m.InitVersion(Tag, Commit, BuildTime) | ||
m.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package connector | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os" | ||
|
||
"go.mau.fi/mautrix-twitter/pkg/twittermeow/data/payload" | ||
Check failure on line 8 in pkg/connector/backfill.go GitHub Actions / Lint (latest)
Check failure on line 8 in pkg/connector/backfill.go GitHub Actions / Lint (latest)
|
||
"go.mau.fi/mautrix-twitter/pkg/twittermeow/data/types" | ||
Check failure on line 9 in pkg/connector/backfill.go GitHub Actions / Lint (latest)
Check failure on line 9 in pkg/connector/backfill.go GitHub Actions / Lint (latest)
|
||
"maunium.net/go/mautrix/bridgev2" | ||
"maunium.net/go/mautrix/bridgev2/networkid" | ||
) | ||
|
||
var _ bridgev2.BackfillingNetworkAPI = (*TwitterClient)(nil) | ||
|
||
func (tc *TwitterClient) FetchMessages(ctx context.Context, params bridgev2.FetchMessagesParams) (*bridgev2.FetchMessagesResponse, error) { | ||
conversationId := string(params.Portal.PortalKey.ID) | ||
cursor := params.Cursor | ||
//count := params.Count | ||
|
||
reqQuery := payload.DmRequestQuery{}.Default() | ||
reqQuery.Count = 25 | ||
messageResp, err := tc.client.FetchConversationContext(conversationId, reqQuery, payload.CONTEXT_FETCH_DM_CONVERSATION_HISTORY) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if cursor != "" { | ||
log.Println("found cursor:", params) | ||
os.Exit(1) | ||
} | ||
|
||
messages, err := messageResp.ConversationTimeline.GetMessageEntriesByConversationID(conversationId, true) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
backfilledMessages, err := tc.MessagesToBackfillMessages(ctx, messages, messageResp.ConversationTimeline.GetConversationByID(conversationId)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
fetchMessagesResp := &bridgev2.FetchMessagesResponse{ | ||
Messages: backfilledMessages, | ||
Cursor: networkid.PaginationCursor(messageResp.ConversationTimeline.MinEntryID), | ||
HasMore: messageResp.ConversationTimeline.Status == types.HAS_MORE, | ||
Forward: params.Forward, | ||
} | ||
|
||
return fetchMessagesResp, nil | ||
} |
Oops, something went wrong.