Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,24 +1051,16 @@ jobs:
- name: Build mesh llama native libraries
if: steps.llama_cache.outputs.cache-hit != 'true'
env:
MESH_REV: ${{ steps.mesh_rev.outputs.rev }}
MESH_REV_SHORT: ${{ steps.mesh_rev.outputs.short }}
run: |
set -euo pipefail
# Check out the pinned mesh-llm rev directly instead of scraping
# Cargo's git/checkouts layout: `cargo fetch` only guarantees the bare
# clone under git/db, so the checkout dir the old `find` looked for is
# frequently absent and the step failed with "checkout not found".
MESH_ROOT="${RUNNER_TEMP:-/tmp}/mesh-llm-$MESH_REV"
rm -rf "$MESH_ROOT"
mkdir -p "$MESH_ROOT"
git -C "$MESH_ROOT" init -q
git -C "$MESH_ROOT" remote add origin https://github.com/Mesh-LLM/mesh-llm.git
git -C "$MESH_ROOT" fetch -q --depth 1 origin "$MESH_REV"
git -C "$MESH_ROOT" checkout -q --detach FETCH_HEAD
[[ -x "$MESH_ROOT/scripts/build-llama.sh" ]] || {
echo "::error::mesh-llm $MESH_REV checked out but scripts/build-llama.sh is missing"
cargo fetch --manifest-path desktop/src-tauri/Cargo.toml
SHORT="$MESH_REV_SHORT"
MESH_ROOT=$(find "${CARGO_HOME:-$HOME/.cargo}/git/checkouts" -path "*/$SHORT" -type d -name "$SHORT" | head -1)
if [[ -z "$MESH_ROOT" ]]; then
echo "::error::mesh-llm checkout for $SHORT not found after cargo fetch"
exit 1
}
fi
export LLAMA_STAGE_BACKEND=metal
export LLAMA_STAGE_BUILD_DIR="$GITHUB_WORKSPACE/.cache/mesh-llama/build-stage-abi-metal"
export CMAKE_OSX_DEPLOYMENT_TARGET=10.15
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,8 @@ jobs:
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/block/buzz-push-gateway,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
# Buildcache lives in the namespace of whichever org runs the
# workflow: GHCR login uses github.repository_owner, so a fork can
# only write its own namespace. Hardcoding block/ made every fork run
# fail the cache export with "permission_denied: The requested
# installation does not exist". Reads still fall back to block's
# public cache so a fork's first build is still warm.
cache-from: |
type=registry,ref=ghcr.io/${{ github.repository_owner }}/buzz-push-gateway-buildcache:${{ matrix.arch }}
type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:${{ matrix.arch }}
cache-to: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref=ghcr.io/{0}/buzz-push-gateway-buildcache:{1},mode=max,compression=zstd', github.repository_owner, matrix.arch) || '' }}
cache-from: type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:${{ matrix.arch }}
cache-to: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:{0},mode=max,compression=zstd', matrix.arch) || '' }}
- name: Export digest
if: github.event_name != 'pull_request'
env:
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,16 @@ jobs:
- name: Build mesh llama native libraries
if: steps.llama_cache.outputs.cache-hit != 'true'
env:
MESH_REV: ${{ steps.mesh_rev.outputs.rev }}
MESH_REV_SHORT: ${{ steps.mesh_rev.outputs.short }}
run: |
set -euo pipefail
# Check out the pinned mesh-llm rev directly instead of scraping
# Cargo's git/checkouts layout: `cargo fetch` only guarantees the bare
# clone under git/db, so the checkout dir the old `find` looked for is
# frequently absent and the step failed with "checkout not found".
MESH_ROOT="${RUNNER_TEMP:-/tmp}/mesh-llm-$MESH_REV"
rm -rf "$MESH_ROOT"
mkdir -p "$MESH_ROOT"
git -C "$MESH_ROOT" init -q
git -C "$MESH_ROOT" remote add origin https://github.com/Mesh-LLM/mesh-llm.git
git -C "$MESH_ROOT" fetch -q --depth 1 origin "$MESH_REV"
git -C "$MESH_ROOT" checkout -q --detach FETCH_HEAD
[[ -x "$MESH_ROOT/scripts/build-llama.sh" ]] || {
echo "::error::mesh-llm $MESH_REV checked out but scripts/build-llama.sh is missing"
cargo fetch --manifest-path desktop/src-tauri/Cargo.toml
SHORT="$MESH_REV_SHORT"
MESH_ROOT=$(find "${CARGO_HOME:-$HOME/.cargo}/git/checkouts" -path "*/$SHORT" -type d -name "$SHORT" | head -1)
if [[ -z "$MESH_ROOT" ]]; then
echo "::error::mesh-llm checkout for $SHORT not found after cargo fetch"
exit 1
}
fi
export LLAMA_STAGE_BACKEND=metal
export LLAMA_STAGE_BUILD_DIR="$GITHUB_WORKSPACE/.cache/mesh-llama/build-stage-abi-metal"
export CMAKE_OSX_DEPLOYMENT_TARGET=10.15
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/signed-macos-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,15 @@ jobs:
- name: Build mesh llama native libraries
if: steps.llama_cache.outputs.cache-hit != 'true'
env:
MESH_REV: ${{ steps.mesh_rev.outputs.rev }}
MESH_REV_SHORT: ${{ steps.mesh_rev.outputs.short }}
run: |
set -euo pipefail
# Check out the pinned mesh-llm rev directly instead of scraping
# Cargo's git/checkouts layout: `cargo fetch` only guarantees the bare
# clone under git/db, so the checkout dir the old `find` looked for is
# frequently absent and the step failed with "checkout not found".
MESH_ROOT="${RUNNER_TEMP:-/tmp}/mesh-llm-$MESH_REV"
rm -rf "$MESH_ROOT"
mkdir -p "$MESH_ROOT"
git -C "$MESH_ROOT" init -q
git -C "$MESH_ROOT" remote add origin https://github.com/Mesh-LLM/mesh-llm.git
git -C "$MESH_ROOT" fetch -q --depth 1 origin "$MESH_REV"
git -C "$MESH_ROOT" checkout -q --detach FETCH_HEAD
[[ -x "$MESH_ROOT/scripts/build-llama.sh" ]] || {
echo "::error::mesh-llm $MESH_REV checked out but scripts/build-llama.sh is missing"
cargo fetch --manifest-path desktop/src-tauri/Cargo.toml
MESH_ROOT=$(find "${CARGO_HOME:-$HOME/.cargo}/git/checkouts" -path "*/$MESH_REV_SHORT" -type d -name "$MESH_REV_SHORT" | head -1)
if [[ -z "$MESH_ROOT" ]]; then
echo "::error::mesh-llm checkout for $MESH_REV_SHORT not found after cargo fetch"
exit 1
}
fi
export LLAMA_STAGE_BACKEND=metal
export LLAMA_STAGE_BUILD_DIR="$GITHUB_WORKSPACE/.cache/mesh-llama/build-stage-abi-metal"
export CMAKE_OSX_DEPLOYMENT_TARGET=10.15
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 2 additions & 62 deletions crates/buzz-relay/src/api/invites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ use axum::{
use serde::Deserialize;
use serde_json::Value;

use crate::handlers::side_effects::{
join_open_channel_member, publish_nip43_member_added, publish_nip43_membership_list,
};
use crate::handlers::side_effects::{publish_nip43_member_added, publish_nip43_membership_list};
use buzz_core::invite::{
hash_v2_code, validate_v2_code, DEFAULT_INVITE_TTL_SECS, MAX_INVITE_TTL_SECS, MAX_INVITE_USES,
MIN_INVITE_TTL_SECS, V2_PREFIX,
Expand All @@ -47,41 +45,6 @@ const CLAIM_RATE_LIMIT: u32 = 10;
/// bound is required in addition to expiry.
pub(crate) const CLAIM_RATE_CACHE_CAPACITY: u64 = 10_000;

fn general_channel_rank(name: &str) -> Option<u8> {
match name.trim().to_ascii_lowercase().as_str() {
// Intent communities pin General first in lexical channel lists.
"0-general" => Some(0),
"general" => Some(1),
_ => None,
}
}

async fn auto_join_general_channel(
tenant: &buzz_core::tenant::TenantContext,
state: &Arc<AppState>,
member_pubkey: &[u8],
) -> anyhow::Result<Option<uuid::Uuid>> {
let channels = state
.db
.list_channels(tenant.community(), Some("open"))
.await?;
let general = channels
.iter()
.filter(|channel| {
channel.channel_type == "stream"
&& channel.archived_at.is_none()
&& general_channel_rank(&channel.name).is_some()
})
.min_by_key(|channel| general_channel_rank(&channel.name));

let Some(general) = general else {
return Ok(None);
};

join_open_channel_member(tenant, general.id, member_pubkey, state).await?;
Ok(Some(general.id))
}

/// Body for `POST /api/invites`.
#[derive(Debug, Default, Deserialize)]
pub struct MintInviteRequest {
Expand Down Expand Up @@ -443,13 +406,6 @@ pub async fn claim_invite(
member = %claimer_hex,
"relay member added via v2 invite"
);
if let Err(e) = auto_join_general_channel(&tenant, &state, &pubkey.to_bytes()).await
{
tracing::warn!(
member = %claimer_hex,
"failed to auto-join General after v2 invite claim: {e}"
);
}
// NIP-43 side effects only on Joined, never on other outcomes.
if let Err(e) = publish_nip43_member_added(&tenant, &state, &claimer_hex).await {
tracing::warn!(
Expand Down Expand Up @@ -528,12 +484,6 @@ pub async fn claim_invite(
member = %claimer_hex,
"relay member added via invite"
);
if let Err(e) = auto_join_general_channel(&tenant, &state, &pubkey.to_bytes()).await {
tracing::warn!(
member = %claimer_hex,
"failed to auto-join General after invite claim: {e}"
);
}
if let Err(e) = publish_nip43_member_added(&tenant, &state, &claimer_hex).await {
tracing::warn!("failed to publish NIP-43 member-added delta after claim: {e}");
}
Expand Down Expand Up @@ -581,22 +531,12 @@ mod tests {
use std::sync::Arc;
use std::time::Duration;

use super::{
claim_key_rate_limited, general_channel_rank, CLAIM_RATE_LIMIT, MAX_INVITE_USES,
MIN_INVITE_TTL_SECS,
};
use super::{claim_key_rate_limited, CLAIM_RATE_LIMIT, MAX_INVITE_USES, MIN_INVITE_TTL_SECS};
use axum::{
body::{to_bytes, Body},
http::{header, Request, StatusCode},
};
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};

#[test]
fn canonical_general_alias_is_preferred_for_invite_auto_join() {
assert_eq!(general_channel_rank("0-general"), Some(0));
assert_eq!(general_channel_rank(" General "), Some(1));
assert_eq!(general_channel_rank("welcome-everyone"), None);
}
use hmac::{Hmac, KeyInit, Mac};
use nostr::{EventBuilder, EventId, Keys, Kind, Tag};
use serde_json::Value;
Expand Down
Loading
Loading