Skip to content

Experimental repository for creating a REST endpoint for searching messages

License

Notifications You must be signed in to change notification settings

beeper/beeper-ingestor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 26, 2025
397f460 Β· Jan 26, 2025

History

2 Commits
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025
Jan 26, 2025

Repository files navigation

beeper-ingestor

A Matrix message search service that uses gomuks internals to save incoming events and provides a REST endpoint for searching messages. Hightly experimental and not for production use.

πŸ€– Note: This repository, including this README, was primarily generated using Large Language Models (LLMs). Code has been tested and works as intended though!

Setup

Prerequisites

  • Go
  • SQLite3
  • Environment variables:
    • GOMUKS_ROOT: Base directory for gomuks data (required)
    • ACCESS_LIST: Authentication credentials in format user:hashedpass|user2:hashedpass2 (required)

GOMUKS_ROOT

The service expects the following directory structure under GOMUKS_ROOT:

GOMUKS_ROOT/
β”œβ”€β”€ cache/
β”œβ”€β”€ config/
β”‚   └── config.yaml  # Required gomuks configuration
β”œβ”€β”€ data/
└── logs/

You can setup the account using gomuks itself and then switch to running this program.

Building

./build.sh

API authentication

The service uses Basic Authentication with SHA-256 hashed passwords. Passwords must be hashed and base64 encoded before being added to the ACCESS_LIST environment variable.

Use the provided generate-password.py script to generate hashed passwords:

python3 generate-password.py <your-password>

Then set the ACCESS_LIST environment variable with username:hashedpassword pairs:

export ACCESS_LIST="user1:hashedpass1|user2:hashedpass2"

API Reference

Search Messages

GET /search-messages

Search for messages with various filters. Requires Basic Authentication.

Query Parameters

Parameter Type Description
room_id string Filter messages by room ID
sender string Filter messages by sender. Will automatically add @ prefix if missing. Must include domain (e.g. @user:domain.com)
before integer Filter messages before this timestamp (milliseconds since epoch)
after integer Filter messages after this timestamp (milliseconds since epoch)
limit integer Maximum number of messages to return (default: 100, max: 1000)
cursor string Pagination cursor (event rowid)
direction string Pagination direction, must be "before" or "after" when cursor is provided

Response Format

{
  "items": [
    {
      "id": "string",
      "timestamp": "number",
      "senderID": "string",
      "text": "string",
      "url": "string",
      "roomInfo": {
        "id": "string",
        "name": "string",
        "url": "string"
      }
    }
  ],
  "has_more": "boolean",
  "oldest_cursor": "string",
  "newest_cursor": "string"
}

Example Request

curl -u username:password 'http://localhost:8080/search-messages?room_id=!roomid:domain.com&limit=10'

About

Experimental repository for creating a REST endpoint for searching messages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published