feat(platform): createGuild publicListing toggle for discovery opt-out
Phase 144 (v0.8.109): createGuild accepts publicListing (default true). recordGuild stores listing preference; announceGuild runs only when listed. Unlisted servers stay invite-only until enabled in server settings. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -33,7 +33,7 @@ Expose a single `EventEmitter` API the UI drives over IPC (`apps/pearcord/index.
|
||||
| `register({ username, displayName })` | `_bootstrapAfterUser` |
|
||||
| `importIdentityBundle(bundle)` | Device pair restore |
|
||||
| `onboarded`, `identity`, `storagePath`, `db`, `dbPath` | Session state |
|
||||
| `listGuilds()`, `loadGuild(guildId)`, `createGuild({ name })`, `joinInvite(code)` | Guild session |
|
||||
| `listGuilds()`, `loadGuild(guildId)`, `createGuild({ name, publicListing? })`, `joinInvite(code)` | Guild session |
|
||||
|
||||
### Messaging & channels
|
||||
|
||||
|
||||
@@ -5014,10 +5014,11 @@ class PearcordPlatform extends EventEmitter {
|
||||
this._restartArchiveHealthRefreshTimer()
|
||||
}
|
||||
|
||||
async createGuild ({ name }) {
|
||||
async createGuild ({ name, publicListing = true } = {}) {
|
||||
const user = this.identity.user
|
||||
if (!user) throw new Error('register first')
|
||||
const hadGuilds = this.guilds.length
|
||||
const listOnDiscovery = publicListing !== false
|
||||
await this._leaveMeshes()
|
||||
await this._closeDM()
|
||||
this.mode = 'guild'
|
||||
@@ -5032,7 +5033,7 @@ class PearcordPlatform extends EventEmitter {
|
||||
const text = result.channels.find((c) => c.type === 'text')
|
||||
if (text) this.selectChannel(text.id)
|
||||
this.guilds = await this.listGuilds()
|
||||
await this.discovery?.recordGuild(result.guild).catch(() => {})
|
||||
await this.discovery?.recordGuild(result.guild, { publicListing: listOnDiscovery }).catch(() => {})
|
||||
if (this.slashCommands) {
|
||||
const builtins = await this.slashCommands.ensureBuiltins()
|
||||
for (const row of builtins) {
|
||||
@@ -5055,10 +5056,12 @@ class PearcordPlatform extends EventEmitter {
|
||||
}
|
||||
}
|
||||
const inv = await this.createInvite().catch(() => null)
|
||||
if (listOnDiscovery) {
|
||||
await this.discovery?.announceGuild(result.guild, {
|
||||
inviteCode: inv?.shareCode || inv?.code || null,
|
||||
memberCount: 1
|
||||
}).catch(() => {})
|
||||
}
|
||||
const isFirstGuild = hadGuilds === 0 && this.guilds.length === 1
|
||||
if (isFirstGuild && this.userSettings) {
|
||||
const prefs = await this.userSettings.getPrefs()
|
||||
|
||||
Reference in New Issue
Block a user