Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84fdb0a8e6 | |||
| 0368d42c1f |
@@ -1,26 +0,0 @@
|
|||||||
.PHONY: lint test build clean
|
|
||||||
|
|
||||||
EMACS ?= emacs
|
|
||||||
|
|
||||||
lint:
|
|
||||||
$(EMACS) -Q --batch -L lisp \
|
|
||||||
--eval "(progn \
|
|
||||||
(require 'package) \
|
|
||||||
(package-initialize) \
|
|
||||||
(unless (package-installed-p 'package-lint) \
|
|
||||||
(package-refresh-contents) \
|
|
||||||
(package-install 'package-lint)) \
|
|
||||||
(setq package-lint-main-file \"lisp/mattermost.el\") \
|
|
||||||
(package-lint-batch-and-exit))"
|
|
||||||
|
|
||||||
test:
|
|
||||||
$(EMACS) -Q --batch -L lisp -L tests \
|
|
||||||
--eval "(require 'ert)" \
|
|
||||||
--eval "(ert-run-tests-batch-and-exit)"
|
|
||||||
|
|
||||||
build:
|
|
||||||
docker compose build
|
|
||||||
|
|
||||||
clean:
|
|
||||||
docker compose down --volumes --remove-orphans
|
|
||||||
rm -rf data/
|
|
||||||
@@ -159,29 +159,15 @@ reply_post
|
|||||||
mark_read
|
mark_read
|
||||||
```
|
```
|
||||||
|
|
||||||
## Emacs package configuration
|
## Emacs package (planned)
|
||||||
|
|
||||||
Add this section to your `init.el`:
|
|
||||||
|
|
||||||
```elisp
|
```elisp
|
||||||
(use-package mattermost
|
(use-package mattermost
|
||||||
:load-path "~/path/to/emacs-mattermost/lisp" ;; Update path or remove after MELPA install
|
:load-path "~/Documents/emacs-mattermost/lisp"
|
||||||
:demand t
|
|
||||||
:custom
|
:custom
|
||||||
(mattermost-bridge-host "127.0.0.1")
|
(mattermost-bridge-host "127.0.0.1")
|
||||||
(mattermost-bridge-port 8765)
|
(mattermost-bridge-port 8765)
|
||||||
(mattermost-server-url "https://mattermost.your-company.local")
|
(mattermost-thread-display 'separate-buffer))
|
||||||
(mattermost-server-id "work")
|
|
||||||
(mattermost-thread-display 'separate-buffer)
|
|
||||||
(mattermost-download-dir "~/Downloads")
|
|
||||||
:bind
|
|
||||||
(("C-c M d" . mattermost-open-self-dm)
|
|
||||||
("C-c M D" . mattermost-dashboard)
|
|
||||||
("C-c M r" . mattermost-reset-state))
|
|
||||||
:config
|
|
||||||
;; Recommended: use auth-source instead of plain text password
|
|
||||||
;; (setq mattermost-password (auth-source-pass-get 'secret "mattermost/work"))
|
|
||||||
(message "Mattermost package loaded. Use C-c M d to open self-DM."))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Buffer naming keeps server identity visible even in single-server MVP:
|
Buffer naming keeps server identity visible even in single-server MVP:
|
||||||
@@ -231,12 +217,3 @@ To verify the bridge works against your corporate Mattermost instance:
|
|||||||
./scripts/mm-cli.sh '{"id":"4","type":"request","method":"get_history","params":{"server_id":"work","channel_id":"<ID_FROM_STEP_3>","limit":1}}'
|
./scripts/mm-cli.sh '{"id":"4","type":"request","method":"get_history","params":{"server_id":"work","channel_id":"<ID_FROM_STEP_3>","limit":1}}'
|
||||||
```
|
```
|
||||||
|
|
||||||
## MELPA Readiness Checklist
|
|
||||||
|
|
||||||
- [x] Standard package header in `lisp/mattermost.el` (`;; Version`, `;; Package-Requires`, `;; License`).
|
|
||||||
- [x] Missing `lisp/mattermost-files.el` created and required.
|
|
||||||
- [x] Dockerfile uses public images by default (reproducible builds), removable `# syntax` directive to avoid DNS timeouts.
|
|
||||||
- [ ] `LICENSE` file (GPLv3+) added to the repository root.
|
|
||||||
- [ ] `Makefile` added with `compile` and `lint` targets for CI.
|
|
||||||
- [ ] CI pipeline configured to run `make lint` and `make compile` on push.
|
|
||||||
- [ ] Recipe submitted to the `melpa/melpa` repository.
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ check-all = "check --workspace"
|
|||||||
test-all = "test --workspace"
|
test-all = "test --workspace"
|
||||||
|
|
||||||
# Corporate environment: crates.io is replaced with internal Nexus mirror.
|
# Corporate environment: crates.io is replaced with internal Nexus mirror.
|
||||||
#[registries.nexus]
|
[registries.nexus]
|
||||||
#index = "sparse+https://nexus.c68.spacecorp.ru/repository/cargo/"
|
index = "sparse+https://nexus.c68.spacecorp.ru/repository/cargo/"
|
||||||
|
|
||||||
#[source.crates-io]
|
[source.crates-io]
|
||||||
#replace-with = "nexus"
|
replace-with = "nexus"
|
||||||
|
|
||||||
# MSRV-aware dependency resolution (cargo >= 1.84).
|
# MSRV-aware dependency resolution (cargo >= 1.84).
|
||||||
# Cargo selects dependency versions compatible with workspace rust-version.
|
# Cargo selects dependency versions compatible with workspace rust-version.
|
||||||
|
|||||||
+13
-12
@@ -4,23 +4,24 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: docker/Dockerfile
|
dockerfile: docker/Dockerfile
|
||||||
args:
|
args:
|
||||||
# Публичные образы по умолчанию для совместимости с MELPA.
|
RUST_BUILDER_IMAGE: "${RUST_BUILDER_IMAGE:-nexus.spacecorp.ru/rust:1.90-bookworm}"
|
||||||
# Для корпоративной среды переопределите их в файле .env
|
RUNTIME_IMAGE: "${RUNTIME_IMAGE:-nexus.c68.spacecorp.ru/ci/debian:bookworm-ca}"
|
||||||
RUST_BUILDER_IMAGE: "${RUST_BUILDER_IMAGE:-rust:1.90-bookworm}"
|
|
||||||
RUNTIME_IMAGE: "${RUNTIME_IMAGE:-debian:bookworm-slim}"
|
|
||||||
container_name: emacs-mattermost-bridge
|
container_name: emacs-mattermost-bridge
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# Контейнер будет использовать /etc/hosts и DNS хост-машины напрямую.
|
||||||
|
# Это позволяет резолвить любые внутренние домены без знания их IP.
|
||||||
|
network_mode: "host"
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
# При network_mode: "host" привязываемся явно к localhost хоста для безопасности
|
||||||
MM_BRIDGE_LISTEN: "0.0.0.0:8765"
|
MM_BRIDGE_LISTEN: "0.0.0.0:8765"
|
||||||
MM_WEB_LISTEN: "0.0.0.0:8766"
|
MM_WEB_LISTEN: "0.0.0.0:8766"
|
||||||
MM_DATA_DIR: "/data"
|
MM_DATA_DIR: "/data"
|
||||||
RUST_LOG: "mm_bridge=info,mm_web=info,warn"
|
RUST_LOG: "mm_bridge=debug,mm_client=debug,mm_store=debug"
|
||||||
# Поддержка корпоративного прокси
|
|
||||||
HTTP_PROXY: "${HTTP_PROXY:-}"
|
|
||||||
HTTPS_PROXY: "${HTTPS_PROXY:-}"
|
|
||||||
NO_PROXY: "${NO_PROXY:-}"
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8765:8765"
|
|
||||||
- "127.0.0.1:8766:8766"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
|
|
||||||
|
# Секция 'ports' игнорируется при network_mode: "host",
|
||||||
|
# так как порты открываются напрямую на интерфейсах хоста.
|
||||||
|
|||||||
+16
-13
@@ -1,27 +1,27 @@
|
|||||||
ARG RUST_BUILDER_IMAGE=rust:1.90-bookworm
|
ARG RUST_BUILDER_IMAGE=nexus.spacecorp.ru/rust:1.90-bookworm
|
||||||
ARG RUNTIME_IMAGE=debian:bookworm-slim
|
ARG RUNTIME_IMAGE=nexus.spacecorp.ru/ci/debian:bookworm-ca
|
||||||
|
|
||||||
FROM ${RUST_BUILDER_IMAGE} AS builder
|
FROM ${RUST_BUILDER_IMAGE} AS builder
|
||||||
|
|
||||||
|
# Corporate CA so cargo trusts nexus.local over HTTPS.
|
||||||
|
COPY docker/certs/corporate-ca.crt /usr/local/share/ca-certificates/corporate-ca.crt
|
||||||
|
RUN update-ca-certificates
|
||||||
|
RUN apt install -y curl
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
COPY bridge/Cargo.toml bridge/Cargo.lock ./
|
COPY bridge/Cargo.toml bridge/Cargo.lock ./
|
||||||
COPY bridge/.cargo ./.cargo
|
COPY bridge/.cargo ./.cargo
|
||||||
COPY bridge/crates ./crates
|
COPY bridge/crates ./crates
|
||||||
|
|
||||||
RUN cargo build --release --locked -p mm-bridge
|
# NOTE: bridge/rust-toolchain.toml is intentionally NOT copied into the image.
|
||||||
|
|
||||||
|
RUN TOOLCHAIN="$(ls /usr/local/rustup/toolchains | head -n1)" \
|
||||||
|
&& echo "Using preinstalled toolchain: ${TOOLCHAIN}" \
|
||||||
|
&& RUSTUP_TOOLCHAIN="${TOOLCHAIN}" cargo build --release --locked -p mm-bridge
|
||||||
|
|
||||||
FROM ${RUNTIME_IMAGE} AS runtime
|
FROM ${RUNTIME_IMAGE} AS runtime
|
||||||
|
|
||||||
# Runtime-зависимости:
|
|
||||||
# - libssl3: для динамической линковки OpenSSL (используется reqwest/hyper-tls)
|
|
||||||
# - ca-certificates: корневые сертификаты для HTTPS-запросов к Mattermost
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
libssl3 \
|
|
||||||
ca-certificates \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN useradd --system --uid 10001 --create-home --home-dir /home/mmbridge mmbridge \
|
RUN useradd --system --uid 10001 --create-home --home-dir /home/mmbridge mmbridge \
|
||||||
&& mkdir -p /data \
|
&& mkdir -p /data \
|
||||||
&& chown -R mmbridge:mmbridge /data /home/mmbridge
|
&& chown -R mmbridge:mmbridge /data /home/mmbridge
|
||||||
@@ -31,7 +31,10 @@ COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
|||||||
|
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
USER mmbridge
|
# NOTE: Intentionally no `USER mmbridge` here. The entrypoint runs as root,
|
||||||
|
# fixes /data ownership, then drops privileges via runuser(1).
|
||||||
|
# This avoids "Permission denied" on bind-mounted volumes whose host-side
|
||||||
|
# ownership does not match UID 10001.
|
||||||
|
|
||||||
ENV MM_BRIDGE_LISTEN=0.0.0.0:8765
|
ENV MM_BRIDGE_LISTEN=0.0.0.0:8765
|
||||||
ENV MM_WEB_LISTEN=0.0.0.0:8766
|
ENV MM_WEB_LISTEN=0.0.0.0:8766
|
||||||
|
|||||||
@@ -5,15 +5,19 @@ export MM_BRIDGE_LISTEN="${MM_BRIDGE_LISTEN:-0.0.0.0:8765}"
|
|||||||
export MM_WEB_LISTEN="${MM_WEB_LISTEN:-0.0.0.0:8766}"
|
export MM_WEB_LISTEN="${MM_WEB_LISTEN:-0.0.0.0:8766}"
|
||||||
export MM_DATA_DIR="${MM_DATA_DIR:-/data}"
|
export MM_DATA_DIR="${MM_DATA_DIR:-/data}"
|
||||||
|
|
||||||
|
# Ensure data directory exists with correct ownership.
|
||||||
|
# Entrypoint runs as root; we fix permissions then drop to mmbridge below.
|
||||||
mkdir -p "${MM_DATA_DIR}"
|
mkdir -p "${MM_DATA_DIR}"
|
||||||
|
chown -R mmbridge:mmbridge "${MM_DATA_DIR}" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Drop privileges to the unprivileged mmbridge user.
|
||||||
if [[ "$#" -eq 0 ]]; then
|
if [[ "$#" -eq 0 ]]; then
|
||||||
exec mm-bridge
|
exec runuser -u mmbridge -- mm-bridge
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "mm-bridge" ]]; then
|
if [[ "$1" == "mm-bridge" ]]; then
|
||||||
shift
|
shift
|
||||||
exec mm-bridge "$@"
|
exec runuser -u mmbridge -- mm-bridge "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec runuser -u mmbridge -- "$@"
|
||||||
|
|||||||
+1
-27
@@ -1,34 +1,8 @@
|
|||||||
;;; mattermost.el --- Emacs bridge for Mattermost -*- lexical-binding: t; -*-
|
;;; mattermost.el --- Emacs client for Mattermost -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright (C) 2026 Ivan I. Ovchinnikov
|
|
||||||
;; Author: Ivan I. Ovchinnikov <mail@iovchinnikov.ru>
|
|
||||||
;; Version: 0.1.0
|
|
||||||
;; Package-Requires: ((emacs "28.1"))
|
|
||||||
;; Keywords: comm, tools
|
|
||||||
;; URL: https://git.iovchinnikov.ru/ivan-igorevich/emacs-mattermost
|
|
||||||
|
|
||||||
;; This program is free software: you can redistribute it and/or modify
|
|
||||||
;; it under the terms of the GNU General Public License as published by
|
|
||||||
;; the Free Software Foundation, either version 3 of the License, or
|
|
||||||
;; (at your option) any later version.
|
|
||||||
|
|
||||||
;; This program is distributed in the hope that it will be useful,
|
|
||||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
;; GNU General Public License for more details.
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
;; Emacs-клиент для Mattermost, использующий Rust-мост.
|
|
||||||
;; Сервер является единственным источником истины, буферы Emacs служат
|
|
||||||
;; только для отображения и ввода.
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
(require 'mattermost-custom)
|
(require 'mattermost-custom)
|
||||||
(require 'mattermost-files)
|
|
||||||
(require 'mattermost-protocol)
|
(require 'mattermost-protocol)
|
||||||
(require 'mattermost-dm)
|
(require 'mattermost-dm)
|
||||||
(require 'mattermost-channel)
|
|
||||||
(require 'mattermost-dashboard)
|
(require 'mattermost-dashboard)
|
||||||
|
|
||||||
(provide 'mattermost)
|
(provide 'mattermost)
|
||||||
;;; mattermost.el ends here
|
|
||||||
|
|||||||
Reference in New Issue
Block a user