Fix profile broadcasting during signup (issue #201) #212

Closed
priyanshu_bharti wants to merge 1 commits from priyanshu_bharti/flotilla:fix/profile-broadcast-on-signup into dev
4 changed files with 20 additions and 15 deletions
+10 -10
View File
@@ -37,21 +37,21 @@
const login = () => pushModal(LogIn)
const completeSignup = () => {
const completeSignup = async () => {
// Add default outbox/inbox relays
publishThunk({
await publishThunk({
event: makeEvent(RELAYS, {tags: DEFAULT_RELAYS.map(url => ["r", url])}),
relays: [...INDEXER_RELAYS, ...DEFAULT_RELAYS],
})
}).complete
// Add default messaging relays
publishThunk({
await publishThunk({
event: makeEvent(MESSAGING_RELAYS, {tags: DEFAULT_MESSAGING_RELAYS.map(url => ["r", url])}),
relays: DEFAULT_RELAYS,
})
}).complete
// Save the user's profile
initProfile(getKey<Profile>("signup.profile")!)
await initProfile(getKey<Profile>("signup.profile")!).complete
// Don't show any notifications for old content
setChecked("*")
@@ -65,23 +65,23 @@
start: () => pushModal(SignUpEmail, {next: flows.email.profile}),
profile: () => pushModal(SignUpProfile, {next: flows.email.complete}),
complete: () => pushModal(SignUpComplete, {next: flows.email.finalize}),
finalize: () => {
finalize: async () => {
const email = getKey<string>("signup.email")!
const clientOptions = getKey<ClientOptions>("signup.clientOptions")!
loginWithPomade(clientOptions, email)
completeSignup()
await completeSignup()
},
},
nostr: {
start: () => pushModal(SignUpProfile, {next: flows.nostr.key}),
key: () => pushModal(SignUpKey, {next: flows.nostr.complete}),
complete: () => pushModal(SignUpComplete, {next: flows.nostr.finalize}),
finalize: () => {
finalize: async () => {
const secret = getKey<string>("signup.secret")!
loginWithNip01(secret)
completeSignup()
await completeSignup()
},
},
}
+1 -1
View File
@@ -71,7 +71,7 @@
await addSpaceMembership(url)
await goto(makeSpacePath(url), {replaceState: true})
broadcastUserData([url])
await broadcastUserData([url])
relaysMostlyRestricted.update(dissoc(url))
pushToast({message: "Welcome to the space!"})
}
+1 -1
View File
@@ -59,7 +59,7 @@
await addSpaceMembership(url)
await goto(makeSpacePath(url), {replaceState: true})
broadcastUserData([url])
await broadcastUserData([url])
relaysMostlyRestricted.update(dissoc(url))
pushToast({message: "Welcome to the space!"})
} catch (e) {
+8 -3
View File
@@ -83,6 +83,7 @@ import {
SETTINGS,
PROTECTED,
INDEXER_RELAYS,
DEFAULT_RELAYS,
DEFAULT_BLOSSOM_SERVERS,
userSpaceUrls,
userSettingsValues,
@@ -125,7 +126,8 @@ export const prependParent = (
export const broadcastUserData = async (relays: string[]) => {
const authors = [pubkey.get()!]
const kinds = [RELAYS, MESSAGING_RELAYS, FOLLOWS, PROFILE]
// Profile is published during onboarding, so space joins should not rebroadcast it.
const kinds = [RELAYS, MESSAGING_RELAYS, FOLLOWS]
const events = repository.query([{kinds, authors}])
for (const event of events) {
@@ -678,6 +680,10 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
// Update Profile
export const initProfile = (profile: Profile) => {
const router = Router.get()
const userRelays = router.FromUser().getUrls()
const relays = userRelays.length ? userRelays : DEFAULT_RELAYS
const template = createProfile(profile)
// Start out protected by default
@@ -685,8 +691,7 @@ export const initProfile = (profile: Profile) => {
const event = makeEvent(PROFILE, template)
// Don't publish anywhere yet, wait until they join a space
return publishThunk({event, relays: []})
return publishThunk({event, relays})
}
export const updateProfile = ({