2 Commits

Author SHA1 Message Date
ivan-igorevich 2612e5ee22 Mac OS tests 2026-11-21 23:51:22 +03:00
ivan-igorevich de7d377e42 added missing file (desynced with dev env on debian) 2026-11-21 22:55:03 +03:00
7 changed files with 133 additions and 21 deletions
+26
View File
@@ -0,0 +1,26 @@
.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/
+26 -3
View File
@@ -159,15 +159,29 @@ reply_post
mark_read mark_read
``` ```
## Emacs package (planned) ## Emacs package configuration
Add this section to your `init.el`:
```elisp ```elisp
(use-package mattermost (use-package mattermost
:load-path "~/Documents/emacs-mattermost/lisp" :load-path "~/path/to/emacs-mattermost/lisp" ;; Update path or remove after MELPA install
: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-thread-display 'separate-buffer)) (mattermost-server-url "https://mattermost.your-company.local")
(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:
@@ -217,3 +231,12 @@ 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.
+4 -4
View File
@@ -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.
+8 -2
View File
@@ -4,8 +4,10 @@ services:
context: . context: .
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
args: args:
RUST_BUILDER_IMAGE: "${RUST_BUILDER_IMAGE:-nexus.spacecorp.ru/rust:1.90-bookworm}" # Публичные образы по умолчанию для совместимости с MELPA.
RUNTIME_IMAGE: "${RUNTIME_IMAGE:-nexus.c68.spacecorp.ru/ci/debian:bookworm-ca}" # Для корпоративной среды переопределите их в файле .env
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
environment: environment:
@@ -13,6 +15,10 @@ services:
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=info,mm_web=info,warn"
# Поддержка корпоративного прокси
HTTP_PROXY: "${HTTP_PROXY:-}"
HTTPS_PROXY: "${HTTPS_PROXY:-}"
NO_PROXY: "${NO_PROXY:-}"
ports: ports:
- "127.0.0.1:8765:8765" - "127.0.0.1:8765:8765"
- "127.0.0.1:8766:8766" - "127.0.0.1:8766:8766"
+12 -11
View File
@@ -1,26 +1,27 @@
ARG RUST_BUILDER_IMAGE=nexus.spacecorp.ru/rust:1.90-bookworm ARG RUST_BUILDER_IMAGE=rust:1.90-bookworm
ARG RUNTIME_IMAGE=nexus.spacecorp.ru/ci/debian:bookworm-ca ARG RUNTIME_IMAGE=debian:bookworm-slim
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
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
# NOTE: bridge/rust-toolchain.toml is intentionally NOT copied into the image. RUN cargo build --release --locked -p mm-bridge
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
+30
View File
@@ -0,0 +1,30 @@
;;; mattermost-files.el --- File attachment helpers -*- lexical-binding: t; -*-
(require 'mattermost-custom)
(require 'mattermost-protocol)
(defun mattermost--format-file-size (bytes)
"Format BYTES as human-readable size."
(cond
((< bytes 1024) (format "%d B" bytes))
((< bytes (* 1024 1024)) (format "%.1f KB" (/ bytes 1024.0)))
((< bytes (* 1024 1024 1024)) (format "%.1f MB" (/ bytes (* 1024.0 1024.0))))
(t (format "%.1f GB" (/ bytes (* 1024.0 1024.0 1024.0))))))
(defun mattermost--format-file-block (files)
"Return a propertized multi-line string describing FILES plist list."
(mapconcat
(lambda (f)
(let* ((name (or (plist-get f :name) "unknown"))
(size (or (plist-get f :size) 0))
(id (plist-get f :id)))
(propertize
(format " 📎 %s (%s)\n" name (mattermost--format-file-size size))
'mm-file-id id
'mm-file-name name
'mouse-face 'highlight
'help-echo "RET to download and open")))
files
""))
(provide 'mattermost-files)
+27 -1
View File
@@ -1,8 +1,34 @@
;;; mattermost.el --- Emacs client for Mattermost -*- lexical-binding: t; -*- ;;; mattermost.el --- Emacs bridge 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