diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5def2a --- /dev/null +++ b/Makefile @@ -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/ diff --git a/README.md b/README.md index 6e99448..3466aed 100644 --- a/README.md +++ b/README.md @@ -159,15 +159,29 @@ reply_post mark_read ``` -## Emacs package (planned) +## Emacs package configuration + +Add this section to your `init.el`: ```elisp (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 (mattermost-bridge-host "127.0.0.1") (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: @@ -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":"","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. diff --git a/bridge/.cargo/config.toml b/bridge/.cargo/config.toml index 5c129d9..549be73 100644 --- a/bridge/.cargo/config.toml +++ b/bridge/.cargo/config.toml @@ -3,11 +3,11 @@ check-all = "check --workspace" test-all = "test --workspace" # Corporate environment: crates.io is replaced with internal Nexus mirror. -[registries.nexus] -index = "sparse+https://nexus.c68.spacecorp.ru/repository/cargo/" +#[registries.nexus] +#index = "sparse+https://nexus.c68.spacecorp.ru/repository/cargo/" -[source.crates-io] -replace-with = "nexus" +#[source.crates-io] +#replace-with = "nexus" # MSRV-aware dependency resolution (cargo >= 1.84). # Cargo selects dependency versions compatible with workspace rust-version. diff --git a/compose.yaml b/compose.yaml index 697f388..c8e3418 100644 --- a/compose.yaml +++ b/compose.yaml @@ -4,8 +4,10 @@ services: context: . dockerfile: docker/Dockerfile args: - RUST_BUILDER_IMAGE: "${RUST_BUILDER_IMAGE:-nexus.spacecorp.ru/rust:1.90-bookworm}" - RUNTIME_IMAGE: "${RUNTIME_IMAGE:-nexus.c68.spacecorp.ru/ci/debian:bookworm-ca}" + # Публичные образы по умолчанию для совместимости с MELPA. + # Для корпоративной среды переопределите их в файле .env + RUST_BUILDER_IMAGE: "${RUST_BUILDER_IMAGE:-rust:1.90-bookworm}" + RUNTIME_IMAGE: "${RUNTIME_IMAGE:-debian:bookworm-slim}" container_name: emacs-mattermost-bridge restart: unless-stopped environment: @@ -13,6 +15,10 @@ services: MM_WEB_LISTEN: "0.0.0.0:8766" MM_DATA_DIR: "/data" RUST_LOG: "mm_bridge=info,mm_web=info,warn" + # Поддержка корпоративного прокси + 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" diff --git a/docker/Dockerfile b/docker/Dockerfile index 5c5978b..138b626 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,26 +1,27 @@ -ARG RUST_BUILDER_IMAGE=nexus.spacecorp.ru/rust:1.90-bookworm -ARG RUNTIME_IMAGE=nexus.spacecorp.ru/ci/debian:bookworm-ca +ARG RUST_BUILDER_IMAGE=rust:1.90-bookworm +ARG RUNTIME_IMAGE=debian:bookworm-slim 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 COPY bridge/Cargo.toml bridge/Cargo.lock ./ COPY bridge/.cargo ./.cargo COPY bridge/crates ./crates -# 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 +RUN cargo build --release --locked -p mm-bridge 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 \ && mkdir -p /data \ && chown -R mmbridge:mmbridge /data /home/mmbridge diff --git a/lisp/mattermost.el b/lisp/mattermost.el index f0e2e50..5f4bce4 100644 --- a/lisp/mattermost.el +++ b/lisp/mattermost.el @@ -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 +;; 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-files) (require 'mattermost-protocol) (require 'mattermost-dm) +(require 'mattermost-channel) (require 'mattermost-dashboard) (provide 'mattermost) +;;; mattermost.el ends here