Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ trim_trailing_whitespace = true
[*.go]
indent_style = tab

[*.{js, jsx, ts, tsx, json, html}]
[*.{js,jsx,ts,tsx,json,html}]
indent_style = space
indent_size = 4

[webapp/package.json]
indent_size = 2

[{Makefile, *.mk}]
[{Makefile,*.mk}]
indent_style = tab

[*.md]
Expand Down
116 changes: 63 additions & 53 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,66 @@
version: "2"

run:
timeout: 5m
modules-download-mode: readonly

linters:
default: none
enable:
- bidichk
- errcheck
- govet
- ineffassign
- makezero
- misspell
- revive
- staticcheck
- unconvert
- unused
- whitespace
settings:
govet:
disable:
- fieldalignment
enable-all: true
exclusions:
generated: lax
presets:
- error
default: none
enable:
- bidichk
- bodyclose
- errcheck
- gocritic
- gosec
- govet
- ineffassign
- makezero
- misspell
- modernize
- nakedret
- revive
- staticcheck
- unconvert
- unqueryvet
- unused
- whitespace
settings:
govet:
enable-all: true
disable:
- fieldalignment
- shadow
revive:
rules:
- name: exported
disabled: true
- name: unused-parameter
disabled: true
unqueryvet:
check-sql-builders: true
exclusions:
paths:
- webapp
- .*/mocks/.*
rules:
Comment thread
fmartingr marked this conversation as resolved.
- path: server/configuration.go
linters:
- unused
- path: _test\.go
linters:
- bodyclose

formatters:
enable:
- goimports
settings:
gofmt:
simplify: true
rewrite-rules:
- pattern: interface{}
replacement: any
exclusions:
generated: lax
paths:
- mock.*
issues:
max-issues-per-linter: 0 # no maximum
max-same-issues: 0 # no maximum
exclude-rules:
- linters:
- revive
text: unused-parameter
- linters:
- gofmt
path: server/matrix/client.go
line: 83
- linters:
- gofmt
path: server/matrix_util.go
line: 151
- linters:
- gofmt
path: server/sync_to_matrix.go
line: 162
enable:
- gofmt
- gofumpt
- goimports
settings:
gofmt:
simplify: true
rewrite-rules:
- pattern: interface{}
replacement: any
goimports:
local-prefixes:
- github.com/mattermost/mattermost-plugin-matrix-bridge
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11
24.13.1
31 changes: 26 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ endif
# Used for semver bumping
PROTECTED_BRANCH := master
APP_NAME := $(shell basename -s .git `git config --get remote.origin.url`)
CURRENT_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0")
CURRENT_VERSION := $(strip $(shell git describe --abbrev=0 --tags))
LATEST_RELEASE_TAG_RAW := $(shell git tag -l "v*" --sort=-v:refname | grep -v '\-rc' | head -n 1 || true)
LATEST_RELEASE_TAG := $(strip $(LATEST_RELEASE_TAG_RAW))
ifeq ($(LATEST_RELEASE_TAG),)
LATEST_RELEASE_TAG := $(CURRENT_VERSION)
endif
VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(CURRENT_VERSION))))
MAJOR := $(word 1,$(VERSION_PARTS))
MINOR := $(word 2,$(VERSION_PARTS))
PATCH := $(word 3,$(VERSION_PARTS))
RC := $(shell echo $(CURRENT_VERSION) | grep -oE 'rc[0-9]+' | sed 's/rc//' || echo "0")
RC := $(shell echo $(CURRENT_VERSION) | grep -oE 'rc[0-9]+' | sed 's/rc//')
# Check if current branch is protected
define check_protected_branch
@current_branch=$$(git rev-parse --abbrev-ref HEAD); \
Expand Down Expand Up @@ -82,6 +87,11 @@ endef
patch: ## to bump patch version (semver)
$(call check_protected_branch)
$(call check_pending_pulls)
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(shell echo $$(($(PATCH)+1))))
$(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH))
@echo Bumping $(APP_NAME) to Patch version $(MAJOR).$(MINOR).$(PATCH)
Expand All @@ -92,6 +102,11 @@ patch: ## to bump patch version (semver)
minor: ## to bump minor version (semver)
$(call check_protected_branch)
$(call check_pending_pulls)
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(shell echo $$(($(MINOR)+1))))
@$(eval PATCH := 0)
$(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH))
Expand All @@ -103,6 +118,11 @@ minor: ## to bump minor version (semver)
major: ## to bump major version (semver)
$(call check_protected_branch)
$(call check_pending_pulls)
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
$(eval MAJOR := $(shell echo $$(($(MAJOR)+1))))
$(eval MINOR := 0)
$(eval PATCH := 0)
Expand Down Expand Up @@ -164,8 +184,8 @@ apply:
## Install go tools
install-go-tools:
@echo Installing go tools
$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
$(GO) install gotest.tools/gotestsum@v1.7.0
$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0
$(GO) install gotest.tools/gotestsum@v1.13.0

## Runs eslint and golangci-lint
.PHONY: check-style
Expand Down Expand Up @@ -193,6 +213,7 @@ ifneq ($(HAS_SERVER),)
ifneq ($(MM_DEBUG),)
$(info DEBUG mode is on; to disable, unset MM_DEBUG)
endif
rm -rf server/dist;
mkdir -p server/dist;
ifneq ($(MM_SERVICESETTINGS_ENABLEDEVELOPER),)
@echo Building plugin only for $(DEFAULT_GOOS)-$(DEFAULT_GOARCH) because MM_SERVICESETTINGS_ENABLEDEVELOPER is enabled
Expand Down Expand Up @@ -412,7 +433,7 @@ help:

mock:
ifneq ($(HAS_SERVER),)
go install github.com/golang/mock/mockgen@v1.6.0
$(GO) install go.uber.org/mock/mockgen@v0.6.0
$(GOBIN)/mockgen -destination=server/command/mocks/mock_commands.go -package=mocks github.com/mattermost/mattermost-plugin-matrix-bridge/server/command Command
$(GOBIN)/mockgen -destination=server/mocks/mock_plugin_api.go -package=mocks github.com/mattermost/mattermost/server/public/plugin API
$(GOBIN)/mockgen -destination=server/mocks/mock_kvstore.go -package=mocks github.com/mattermost/mattermost-plugin-matrix-bridge/server/store/kvstore KVStore
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,25 @@ A bidirectional bridge that connects Mattermost and Matrix, enabling real-time m
## Quick Start

### 1. Install Plugin

- Download from [releases](https://github.com/mattermost/mattermost-plugin-matrix-bridge/releases)
- Upload via System Console → Plugins → Plugin Management

### 2. Configure Settings

- Go to System Console → Plugins → Matrix Bridge
- Set your Matrix homeserver URL (e.g., `https://matrix.example.com`)
- Generate Application Service and Homeserver tokens
- Enable message synchronization

### 3. Setup Matrix Homeserver

- Download the registration file from the admin console
- Add it to your Matrix homeserver's `app_service_config_files`
- Restart your homeserver

### 4. Connect Channels

Use slash commands to bridge channels:

```
Expand All @@ -51,6 +55,7 @@ Use slash commands to bridge channels:
3. **Start Chatting**: Messages automatically sync between platforms with full user attribution

**What Gets Synced:**

- Messages (with formatting and mentions)
- Emoji reactions (4,400+ emoji support)
- Message edits and deletions
Expand All @@ -65,12 +70,12 @@ Use slash commands to bridge channels:

## Configuration

| Setting | Description |
|---------|-------------|
| Matrix Server URL | Your Matrix homeserver URL |
| Setting | Description |
| ------------------------- | ----------------------------------------- |
| Matrix Server URL | Your Matrix homeserver URL |
| Application Service Token | Generated token for Matrix authentication |
| Homeserver Token | Generated token for webhook security |
| Enable Message Sync | Toggle bidirectional synchronization |
| Homeserver Token | Generated token for webhook security |
| Enable Message Sync | Toggle bidirectional synchronization |

## Development

Expand Down Expand Up @@ -100,20 +105,23 @@ For local development and testing, you can run a Matrix Synapse server using Doc
### Prerequisites

1. Install and configure the Mattermost Matrix Bridge plugin first
- **Matrix Server URL**: `http://localhost:8888`
2. Generate the bridge registration file through the plugin configuration
3. Copy the generated registration file to `docker/mattermost-bridge-registration.yaml`

### Starting the Matrix Synapse Server

1. Start the services:
```bash
docker-compose up -d
```

```bash
docker-compose up -d
```

2. Create an admin user:
```bash
docker exec -it mattermost-plugin-matrix-bridge-synapse-1 register_new_matrix_user -c /data/homeserver.yaml -u admin -p admin123 -a http://localhost:8008
```

```bash
docker exec -it mattermost-plugin-matrix-bridge-synapse-1 register_new_matrix_user -c /data/homeserver.yaml -u admin -p admin123 -a http://localhost:8008
```

3. The Matrix server will be available at `http://localhost:8888`

Expand All @@ -131,18 +139,21 @@ docker-compose down
```

To completely reset (remove all data):

```bash
docker-compose down -v
```

## Troubleshooting

**Connection Issues:**

- Verify Matrix server URL and tokens are correct
- Check that registration file is installed on Matrix homeserver
- Use `/matrix status` to diagnose problems

**Sync Problems:**

- Ensure channel is configured for shared channels
- Check that both platforms can reach each other
- Review plugin logs for detailed error information
Expand Down
Loading
Loading