mautrix / whatsapp

A Matrix-WhatsApp puppeting bridge
https://maunium.net/go/mautrix-whatsapp
GNU Affero General Public License v3.0
1.21k stars 170 forks source link

Bot account not created with conduit server. Error in bridge logs shows: M_FORBIDDEN: User does not exist. #678

Closed jmaris closed 5 months ago

jmaris commented 6 months ago

After starting the bot, I get the following error:

2023-12-23T23:16:27Z INF Initializing bridge built_at="Dec 19 2023, 12:57:29" go_version=go1.21.5 name=mautrix-whatsapp version=0.10.5+dev.a1f1c91b
2023-12-23T23:16:27Z DBG Initializing database connection
2023-12-23T23:16:27Z DBG Initializing state store
2023-12-23T23:16:27Z DBG Initializing Matrix event processor
2023-12-23T23:16:27Z DBG Initializing Matrix event handler
2023-12-23T23:16:27Z DBG Bridge built with end-to-bridge encryption, but disabled in config
2023-12-23T23:16:27Z INF Bridge initialization complete, starting...
2023-12-23T23:16:27Z DBG Running database upgrades
2023-12-23T23:16:27Z INF Database is up to date current_version=57 db_section=main latest_known_version=57 oldest_compatible_version=45
2023-12-23T23:16:27Z INF Database is up to date current_version=5 db_section=matrix_state latest_known_version=5 oldest_compatible_version=5
2023-12-23T23:16:27Z DBG Starting application service HTTP server
2023-12-23T23:16:27Z DBG Checking connection to homeserver
2023-12-23T23:16:27Z INF Starting HTTP listener address=0.0.0.0:29318
2023-12-23T23:16:27Z DBG Request completed as_user_id=@whatsappbot:jmaris.me duration=1.818771 method=GET req_id=1 response_length=118 response_mime=application/json status_code=200 url=http://matrix:6167/_matrix/client/versions?user_id=%40whatsappbot%3Ajmaris.me
2023-12-23T23:16:27Z DBG Request completed as_user_id=@whatsappbot:jmaris.me duration=0.44378 method=GET req_id=2 response_length=69 response_mime=application/json status_code=403 url=http://matrix:6167/_matrix/client/v3/account/whoami?user_id=%40whatsappbot%3Ajmaris.me
2023-12-23T23:16:27Z FTL /whoami request failed with unknown error error="failed to GET /_matrix/client/v3/account/whoami: M_FORBIDDEN (HTTP 403): M_FORBIDDEN: User does not exist."

``

I have set up mautrix-whatsapp with conduit using docker compose with the following compose file. I have checked that matrix is accessible for containers inside the compose file, but I can't check that the bridge is accessible from the matrix server because the bridge constantly restarts.

version: '3'

services: homeserver: image: matrixconduit/matrix-conduit:latest container_name: matrix restart: unless-stopped ports:

the bridge config is as follows:

# Homeserver details.
homeserver:
    address: http://matrix:6167
    domain: (redacted)

    software: standard
    status_endpoint: null
    message_send_checkpoint_endpoint: null
    async_media: false
    websocket: false
    ping_interval_seconds: 0

appservice:
    address: http://mautrix-whatsapp:29318
    hostname: 0.0.0.0
    port: 29318

    database:
        type: postgres
        uri: postgres://(redacted):(redacted)@bridgedb/whatsapp?sslmode=disable
        max_open_conns: 20
        max_idle_conns: 2
        max_conn_idle_time: null
        max_conn_lifetime: null

    id: whatsapp
    bot:
        username: whatsappbot
        displayname: WhatsApp bridge bot
        avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr
    ephemeral_events: true
    async_transactions: false

    as_token: "(redacted)"
    hs_token: "(redacted)"

# Config for things that are directly sent to WhatsApp.
whatsapp:
    os_name: Mautrix-WhatsApp bridge
    browser_name: unknown

# Bridge config
bridge:
    username_template: whatsapp_{{.}}
    displayname_template: "{{or .BusinessName .PushName .JID}} (WA)"
    personal_filtering_spaces: false
    delivery_receipts: false
    message_status_events: false
    message_error_notices: true
    call_start_notices: true
    identity_change_notices: false
    portal_message_buffer: 128
    history_sync:
        backfill: true
        max_initial_conversations: -1
        message_count: 50
        request_full_sync: false
        full_sync_config:
            days_limit: null
            size_mb_limit: null
            storage_quota_mb: null
        unread_hours_threshold: 0

        media_requests:
            auto_request_media: true
            request_method: immediate
            request_local_time: 120
        immediate:
            worker_count: 1
            max_events: 10
        deferred:
            - start_days_ago: 7
              max_batch_events: 20
              batch_delay: 5
            - start_days_ago: 30
              max_batch_events: 50
              batch_delay: 10
            - start_days_ago: 90
              max_batch_events: 100
              batch_delay: 10
            - start_days_ago: -1
              max_batch_events: 500
              batch_delay: 10
    user_avatar_sync: true
    bridge_matrix_leave: true
    sync_direct_chat_list: false
    sync_manual_marked_unread: true
    default_bridge_presence: true
    send_presence_on_typing: false
    force_active_delivery_receipts: false
    double_puppet_server_map:
        example.com: https://example.com
    double_puppet_allow_discovery: false
    login_shared_secret_map:
        example.com: foobar
    private_chat_portal_meta: default
    parallel_member_sync: false
    bridge_notices: true
    resend_bridge_info: false
    mute_bridging: false
    archive_tag: null
    pinned_tag: null
    tag_only_on_create: true
    enable_status_broadcast: true
    disable_status_broadcast_send: true
    mute_status_broadcast: true
    status_broadcast_tag: m.lowpriority
    whatsapp_thumbnail: false
    allow_user_invite: false
    federate_rooms: true
    disable_bridge_alerts: false
    crash_on_stream_replaced: false
    url_previews: false
    caption_in_message: false
    beeper_galleries: false
    extev_polls: false
    cross_room_replies: false
    disable_reply_fallbacks: false
    message_handling_timeout:
        error_after: null
        deadline: 120s

    command_prefix: "!wa"

    management_room_text:
        welcome: "Hello, I'm a WhatsApp bridge bot."
        welcome_connected: "Use `help` for help."
        welcome_unconnected: "Use `help` for help or `login` to log in."
        additional_help: ""

    encryption:
        allow: false
        default: false
        appservice: false
        require: false
        allow_key_sharing: false
        plaintext_mentions: false
        delete_keys:
            delete_outbound_on_ack: false
            dont_store_outbound: false
            ratchet_on_decrypt: false
            delete_fully_used_on_decrypt: false
            delete_prev_on_new_session: false
            delete_on_device_delete: false
            periodically_delete_expired: false
            delete_outdated_inbound: false
        verification_levels:
            receive: unverified
            send: unverified
            share: cross-signed-tofu
        rotation:
            enable_custom: false
            milliseconds: 604800000
            messages: 100
            disable_device_change_key_rotation: false

    provisioning:
        prefix: /_matrix/provision
        shared_secret: (redacted)
        debug_endpoints: false

    permissions:
        "*": relay
        "(redacted server domain)": user
        "(redacted @username:serverdomain)": admin

    relay:
        enabled: false
        admin_only: true
        message_formats:
            m.text: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
            m.notice: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
            m.emote: "* <b>{{ .Sender.Displayname }}</b> {{ .Message }}"
            m.file: "<b>{{ .Sender.Displayname }}</b> sent a file"
            m.image: "<b>{{ .Sender.Displayname }}</b> sent an image"
            m.audio: "<b>{{ .Sender.Displayname }}</b> sent an audio file"
            m.video: "<b>{{ .Sender.Displayname }}</b> sent a video"
            m.location: "<b>{{ .Sender.Displayname }}</b> sent a location"
kubo6472 commented 6 months ago

@jmaris if you use @conduit:domain.tld: create-user whatsappbot it will work

jmaris commented 5 months ago

Thanks :)