mirror of
https://github.com/block/buzz.git
synced 2026-11-07 18:01:06 +00:00
## Summary - add a permission-gated mobile community invite page - create, copy, and natively share configurable invite links - invite a validated npub directly with member/admin role selection - reuse Buzz profile actions, search styling, settings rows, and modal sheets ## Validation - `just mobile-check` - `flutter test` (1,275 tests) - Pixel and iPhone review builds installed and launched --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Kenny Lopez <klopez4212@gmail.com> Signed-off-by: Fast Fizz <2df81cb51f05a9d5387ef24d7b9ecb8fcdfcd1c70ffabc67061c9596e1b5b1c4@buzz.block.builderlab.xyz> Co-authored-by: Carl <3c4caeafb646d23867f1c4832e68211d77e2561946171625f75c3ce1a3f2670f@buzz.block.builderlab.xyz> Co-authored-by: Fast Fizz <2df81cb51f05a9d5387ef24d7b9ecb8fcdfcd1c70ffabc67061c9596e1b5b1c4@buzz.block.builderlab.xyz>
73 lines
2.1 KiB
Dart
73 lines
2.1 KiB
Dart
import 'package:buzz/shared/community/community_membership_provider.dart';
|
|
import 'package:buzz/shared/relay/relay.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
const owner =
|
|
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
|
|
const admin =
|
|
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
|
|
const member =
|
|
'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc';
|
|
|
|
test('parses Buzz and legacy membership tags with roles', () {
|
|
final snapshot = communityMembershipFromEvents([
|
|
_event(
|
|
createdAt: 2,
|
|
tags: [
|
|
['member', owner, 'owner'],
|
|
['member', admin.toUpperCase(), 'admin'],
|
|
['p', member, 'wss://relay.example.com', 'member'],
|
|
['member', 'not-a-pubkey', 'owner'],
|
|
['member', owner, 'member'],
|
|
],
|
|
),
|
|
]);
|
|
|
|
expect(snapshot.snapshotFound, isTrue);
|
|
expect(snapshot.members, hasLength(3));
|
|
expect(snapshot.roleFor(owner), CommunityMemberRole.owner);
|
|
expect(snapshot.roleFor(admin), CommunityMemberRole.admin);
|
|
expect(snapshot.roleFor(member), CommunityMemberRole.member);
|
|
expect(snapshot.pubkeys, {owner, admin, member});
|
|
});
|
|
|
|
test('uses the latest membership snapshot', () {
|
|
final snapshot = communityMembershipFromEvents([
|
|
_event(
|
|
createdAt: 1,
|
|
tags: [
|
|
['member', owner, 'owner'],
|
|
],
|
|
),
|
|
_event(
|
|
createdAt: 2,
|
|
tags: [
|
|
['member', owner, 'admin'],
|
|
],
|
|
),
|
|
]);
|
|
|
|
expect(snapshot.roleFor(owner), CommunityMemberRole.admin);
|
|
});
|
|
|
|
test('fails closed when no snapshot is available', () {
|
|
final snapshot = communityMembershipFromEvents(const []);
|
|
|
|
expect(snapshot.snapshotFound, isFalse);
|
|
expect(snapshot.members, isEmpty);
|
|
expect(canManageCommunityInvites(snapshot.roleFor(owner)), isFalse);
|
|
});
|
|
}
|
|
|
|
NostrEvent _event({required int createdAt, required List<List<String>> tags}) =>
|
|
NostrEvent(
|
|
id: '$createdAt',
|
|
pubkey: 'relay',
|
|
createdAt: createdAt,
|
|
kind: EventKind.relayMembership,
|
|
tags: tags,
|
|
content: '',
|
|
sig: '',
|
|
);
|