Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

megatwitter (v2) #41

Closed
wants to merge 94 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
e796813
v2: delete old bridge and add stub v2 bridge
tulir Jul 19, 2024
368933e
twittermeow: copy x-go library into repo
tulir Jul 19, 2024
5f9a275
lint: add ignores for staticcheck errors
tulir Jul 19, 2024
bbe7cac
current progress state
0xzer Aug 9, 2024
0c57f04
read receipts / more twitter events
0xzer Aug 10, 2024
21edd8e
events for name update, delete conv, new members
0xzer Aug 12, 2024
238705d
handletwit: Removed deprecated SimpleRemoteEvent
purpshell Oct 9, 2024
b8aa05d
chore: formatting and organizing imports
purpshell Oct 9, 2024
fd94d89
client: add more network room capabilities
purpshell Oct 9, 2024
f95502d
chore: go mod tidy + use official mautrix-go repo
purpshell Oct 9, 2024
72d7985
chore: linting and warnings
purpshell Oct 9, 2024
4bc2822
ci: lock closed issues automatically after 90 days
tulir Sep 28, 2024
d9e5394
.github: update bug report template
tulir Oct 9, 2024
a047281
ci: run lint on go 1.23
tulir Oct 9, 2024
ab70a18
ci: update pre-commit hooks
tulir Oct 9, 2024
80f9369
twittermeow: Implement Disconnect and Logout methods
purpshell Oct 9, 2024
3f647b6
client: Implement Disconnect/Logout/IsLoggedIn/IsThisUser
purpshell Oct 9, 2024
6fd7913
client: Implement Disconnect/Logout/IsLoggedIn/IsThisUser
purpshell Oct 9, 2024
036c300
connector: clean redundant code / use NewTwitterClient
purpshell Oct 9, 2024
9c6b340
Merge remote-tracking branch 'origin/v2' into v2
purpshell Oct 9, 2024
45136b4
client: bugfix - include connector in new client
purpshell Oct 10, 2024
05f44e9
handlematrix: Fix M->T GIF sending
purpshell Oct 10, 2024
2563d54
twittermeow: Implement Push Sub/Unsub
purpshell Oct 10, 2024
2a9f98e
client: Implement Remote Push
purpshell Oct 10, 2024
4fb4ffe
config: add base network config
purpshell Oct 10, 2024
153a3a1
roadmap: updated to reflect currently tested & working features
purpshell Oct 11, 2024
bba9eff
main: update version to 0.2.0
purpshell Oct 11, 2024
6972a23
account,client: update push setting enum to avoid confusion
purpshell Oct 11, 2024
ecde01b
twittermeow/methods: Add method to create a conversation id
purpshell Oct 11, 2024
f5b5d37
startchat: Add identifier resolving functionality
purpshell Oct 11, 2024
490e792
mapping: Add identifier property to user info
purpshell Oct 11, 2024
e9bea8a
config,mapping: Add displaynameTemplate functionality / remove redund…
purpshell Oct 11, 2024
d0de436
twittermeow: Rename to DeleteMessageForMe to reflect feature
purpshell Oct 11, 2024
76ce8db
twittermeow: Edit messages and receive edits
purpshell Oct 11, 2024
0b610fe
handlematrix,handletwit: Edit messages and receive edits
purpshell Oct 11, 2024
fb97257
startchat,twittermeow, go.mod: linting
purpshell Oct 11, 2024
1527f1a
mapping: fix gif sending rendering bug & clean warnings
purpshell Oct 12, 2024
928a88b
twittermeow,connector: clean warnings
purpshell Oct 12, 2024
e77635c
main: remove dependence on NewConnector method
purpshell Oct 16, 2024
73e2d68
Code review suggestions: tulir(batch 1)
purpshell Oct 16, 2024
d0a9162
Update pkg/connector/login.go
purpshell Oct 16, 2024
255ac4d
client,mapping: Remove message part ids & merge captions
purpshell Oct 16, 2024
0c8de63
account, methods: Use built-in unpadded b64 function
purpshell Oct 17, 2024
479005a
methods, client_sync, client: Remove redundant MergeMaps and RandStr …
purpshell Oct 17, 2024
7ab73a4
client, connector: do LoadMessagesPage during Connect instead of Load…
purpshell Oct 17, 2024
557f94e
dbmeta: add explicit json field for cookies in struct
purpshell Oct 17, 2024
7484471
events: Remove XEventConversationRead ( does not even work )
purpshell Oct 17, 2024
a584ba3
methods: remove the GenerateEventValue / GetTimestampMS functions
purpshell Oct 17, 2024
758db79
mapping: remove redundant check and get file directly in MakeAvatar
purpshell Oct 17, 2024
e49c056
mapping,client,handletwit: remove duplicate in MessagesToBackfillMess…
purpshell Oct 17, 2024
91e3ba8
mapping: Upload T->M using file streams
purpshell Oct 17, 2024
b9d8a7b
handlematrix: Remove redundant case, the mediatype parameter and erro…
purpshell Oct 17, 2024
39b6a14
account: add content type
purpshell Oct 17, 2024
41ed6de
messaging, handlematrix: send M->T typing notifications
purpshell Oct 17, 2024
71734ba
login, roadmap: cleanup/linting
purpshell Oct 17, 2024
17af8a2
login, main: legacy provisioning + legacy config migration
purpshell Oct 18, 2024
70fe6b1
pre-commit: add some failures
tulir Oct 16, 2024
c7a8608
twittermeow: use net/http types for method name fields
purpshell Oct 21, 2024
6f8fd76
login, main: legacy DB migration
purpshell Oct 21, 2024
c60910b
ci: use default docker tag format
tulir Oct 25, 2024
3af5571
ci: rename dockerfile
tulir Oct 25, 2024
5aef8b4
legacymigrate: set pickle key + construct cookies as a string instead…
purpshell Oct 25, 2024
cf3e8f1
Merge remote-tracking branch 'origin/v2' into v2
purpshell Oct 25, 2024
d0447a9
legacymigrate: properly state preprocessor directive
purpshell Oct 25, 2024
a3500f3
legacyprovision: fix cookies and API path
purpshell Oct 28, 2024
feb9d35
legacyprovision: Added whoami function
purpshell Oct 28, 2024
d2fdb22
legacyprovision: remove /login 200 payload
purpshell Oct 28, 2024
b7411f3
client,login: send connected bridge state
purpshell Oct 28, 2024
919f60e
login: reuse userlogin
purpshell Oct 28, 2024
3e092cc
backfill: Improved backfilling
purpshell Oct 28, 2024
3a782e3
config: remove username_template upgrade
purpshell Oct 28, 2024
ee8667d
backfill: Use anchor message along the cursor
purpshell Oct 31, 2024
e83e214
config: remove unused displayname_max_length config option
tulir Nov 22, 2024
d6f4bdf
legacymigrate: don't try to guess message sender
tulir Nov 22, 2024
7fd857e
client,login: add missing error message
tulir Nov 22, 2024
cfee470
twittermeow/client: disable jot
tulir Nov 22, 2024
026c749
twittermeow/session: ignore missing screen name
tulir Nov 22, 2024
5c99708
backfill: don't try to use non-existent anchor message
tulir Nov 22, 2024
9a96655
legacymigrate: fix more bugs
tulir Nov 25, 2024
4a93f12
connector: fix various issues
tulir Nov 25, 2024
22b992f
all: fix name casing consistency
tulir Nov 25, 2024
7c878f9
twittermeow/methods: simplify some utilities
tulir Nov 25, 2024
5b5ebef
backfill: add more logs
tulir Nov 25, 2024
612377f
twittermeow: use snowflakes properly
tulir Nov 25, 2024
28b614d
legacymigrate: fix members_fetched field
tulir Nov 25, 2024
235d5e5
backfill: fix handling empty responses
tulir Nov 25, 2024
4037aa8
legacymigrate: fix column name
tulir Nov 25, 2024
f75f6b7
twittermeow/http: log polling on trace level
tulir Nov 25, 2024
80a44b1
dependencies: update
tulir Nov 26, 2024
b83b210
legacymigrate: fix room type and other user ID migration
tulir Nov 26, 2024
eeb97a0
ci: add missing env var
tulir Nov 26, 2024
3ee7267
client: don't sync conversations with no messages
tulir Nov 26, 2024
8aa401c
legacymigrate: handle null ghost info
tulir Nov 26, 2024
c41a01c
legacymigrate: handle missing reaction ids
tulir Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.py]
max_line_length = 99

[*.{yaml,yml,py}]
[*.{yaml,yml,sql}]
indent_style = space

[{.gitlab-ci.yml,.pre-commit-config.yaml}]
[{.gitlab-ci.yml,.github/workflows/*.yml}]
indent_size = 2
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Bug report
about: If something is definitely wrong in the bridge (rather than just a setup issue),
file a bug report. Remember to include relevant logs.
labels: bug

---

<!--
Remember to include relevant logs, the bridge version and any other details.
If you aren't sure what's needed, ask in the Matrix room rather than opening an
incomplete issue. Issues with insufficient detail will likely just be ignored.
-->
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contact_links:
- name: Troubleshooting docs & FAQ
url: https://docs.mau.fi/bridges/general/troubleshooting.html
about: Check this first if you're having problems setting up the bridge.
- name: Support room
url: https://matrix.to/#/#twitter:maunium.net
about: For setup issues not answered by the troubleshooting docs, ask in the Matrix room.
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: Enhancement request
about: Submit a feature request or other suggestion
labels: enhancement

---
36 changes: 36 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Go

on: [push, pull_request]

env:
GOTOOLCHAIN: local

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ["1.22", "1.23"]
name: Lint ${{ matrix.go-version == '1.23' && '(latest)' || '(old)' }}

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true

- name: Install libolm
run: sudo apt-get install libolm-dev libolm3

- 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: Run pre-commit
uses: pre-commit/[email protected]
26 changes: 0 additions & 26 deletions .github/workflows/python-lint.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Lock old issues'

on:
schedule:
- cron: '0 18 * * *'
workflow_dispatch:

permissions:
issues: write
# pull-requests: write
# discussions: write

concurrency:
group: lock-threads

jobs:
lock-stale:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
id: lock
with:
issue-inactive-days: 90
process-only: issues
- name: Log processed threads
run: |
if [ '${{ steps.lock.outputs.issues }}' ]; then
echo "Issues:" && echo '${{ steps.lock.outputs.issues }}' | jq -r '.[] | "https://github.com/\(.owner)/\(.repo)/issues/\(.issue_number)"'
fi
25 changes: 7 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
/.idea/

/.venv
/env/
pip-selfcheck.json
*.pyc
__pycache__
/build
/dist
/*.egg-info
/.eggs
./mautrix-twitter
logs/
*.db*
*.yaml
!example-config.yaml
!.pre-commit-config.yaml
/start

/config.yaml
/registration.yaml
*.log*
*.db
*.pickle
*.bak
/pkg/mautrix
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include:
- project: 'mautrix/ci'
file: '/python.yml'
file: '/gov2-as-default.yml'
28 changes: 18 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude_types: [markdown]
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.1.0

- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: black
language_version: python3
files: ^(mautwitdm|mautrix_twitter)/.*\.pyi?$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- id: go-imports-repo
args:
- "-local"
- "go.mau.fi/mautrix-twitter"
- "-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: isort
files: ^(mautwitdm|mautrix_twitter)/.*\.pyi?$
- id: zerolog-ban-msgf
- id: zerolog-use-stringer
- id: prevent-literal-http-methods
39 changes: 0 additions & 39 deletions Dockerfile

This file was deleted.

15 changes: 15 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:3.20

ENV UID=1337 \
GID=1337

RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq-go

ARG EXECUTABLE=./mautrix-twitter
COPY $EXECUTABLE /usr/bin/mautrix-twitter
COPY ./docker-run.sh /docker-run.sh
ENV BRIDGEV2=1
VOLUME /data
WORKDIR /data

CMD ["/docker-run.sh"]
12 changes: 12 additions & 0 deletions LICENSE.exceptions
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The mautrix-twitter developers grant the following special exceptions:

* to Beeper the right to embed the program in the Beeper clients and servers,
and use and distribute the collective work without applying the license to
the whole.
* to Element the right to distribute compiled binaries of the program as a part
of the Element Server Suite and other server bundles without applying the
license.

All exceptions are only valid under the condition that any modifications to
the source code of mautrix-twitter remain publicly available under the terms
of the GNU AGPL version 3 or later.
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

28 changes: 12 additions & 16 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
# Features & roadmap

* Matrix → Twitter
* [ ] Message content
* [x] Message content
* [x] Text
* [ ] Formatting
* [ ] Media
* [ ] ~~Formatting~~ (not supported by Twitter)
* [x] Media
* [x] Images
* [x] Videos
* [x] Gifs
* [x] Message reactions
* [ ] Typing notifications
* [x] Typing notifications
* [x] Read receipts
* Twitter → Matrix
* [ ] Message content
* [x] Message content
* [x] Text
* [ ] Formatting
* [ ] ~~Formatting~~ (not supported by Twitter)
* [x] Media
* [x] Images
* [x] Videos
* [x] Gifs
* [x] Message reactions
* [x] Message history
* [x] When creating portal
* [x] Missed messages
* [ ] Message history
* [ ] When creating portal
* [ ] Missed messages
* [x] Avatars
* [ ] † Typing notifications
* [ ] † Read receipts
* Misc
* [x] Automatic portal creation
* [x] At startup
* [ ] At startup
* [x] When receiving invite or message
* [x] Provisioning API for logging in
* [ ] Private chat creation by inviting Matrix puppet of Twitter user to new room
* [ ] Option to use own Matrix account for messages sent from other Twitter clients
* [x] Automatic login with shared secret
* [ ] Manual login with `login-matrix`
* [x] E2EE in Matrix rooms
* [ ] E2EE in Matrix rooms

† Information not automatically sent from source, i.e. implementation may not be possible
‡ Maybe, i.e. this feature may or may not be implemented at some point
† Implementation is impossible / really difficult at the current state of the mautrix-go framework
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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 "$@"
24 changes: 24 additions & 0 deletions cmd/mautrix-twitter/legacymigrate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
_ "embed"

up "go.mau.fi/util/configupgrade"
"maunium.net/go/mautrix/bridgev2/bridgeconfig"
)

const legacyMigrateRenameTables = `
ALTER TABLE portal RENAME TO portal_old;
ALTER TABLE puppet RENAME TO puppet_old;
ALTER TABLE message RENAME TO message_old;
ALTER TABLE reaction RENAME TO reaction_old;
ALTER TABLE "user" RENAME TO user_old;
`

//go:embed legacymigrate.sql
var legacyMigrateCopyData string

func migrateLegacyConfig(helper up.Helper) {
helper.Set(up.Str, "mautrix.bridge.e2ee", "encryption", "pickle_key")
bridgeconfig.CopyToOtherLocation(helper, up.Int, []string{"bridge", "displayname_max_length"}, []string{"network", "displayname_max_length"})
}
Loading