a tool for shared writing and social publishing

fix: prevent user from subscribing to own publication #1

closed opened by ewancroft.uk targeting main from [deleted fork]: prevent-user-from-subscription-to-own-pub
Labels

None yet.

assignee

None yet.

Participants 3
AT URI
at://did:plc:ofrbh253gwicbkc5nktqepol/sh.tangled.repo.pull/3m643mhubx522
+15
Diff #0
+10
app/lish/Subscribe.tsx
··· 186 186 pub_uri: string; 187 187 base_url: string; 188 188 subscribers: { identity: string }[]; 189 + pub_creator?: string; 189 190 }) => { 190 191 let { identity } = useIdentityData(); 191 192 let searchParams = useSearchParams(); ··· 195 196 let subscribed = 196 197 identity?.atp_did && 197 198 props.subscribers.find((s) => s.identity === identity.atp_did); 199 + 200 + // Check if the logged-in user is the publication owner 201 + let isOwner = identity?.atp_did && props.pub_creator === identity.atp_did; 198 202 199 203 if (successModalOpen) 200 204 return ( ··· 203 207 setOpen={setSuccessModalOpen} 204 208 /> 205 209 ); 210 + 211 + // Don't allow users to subscribe to their own publication 212 + if (isOwner) { 213 + return null; 214 + } 215 + 206 216 if (subscribed) { 207 217 return <ManageSubscription {...props} />; 208 218 }
+4
app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx
··· 129 129 pubName={ 130 130 document.documents_in_publications[0].publications.name 131 131 } 132 + pub_creator={ 133 + document.documents_in_publications[0].publications 134 + .identity_did 135 + } 132 136 /> 133 137 )} 134 138 </div>
+1
app/lish/[did]/[publication]/page.tsx
··· 107 107 pubName={publication.name} 108 108 pub_uri={publication.uri} 109 109 subscribers={publication.publication_subscriptions} 110 + pub_creator={publication.identity_did} 110 111 /> 111 112 </div> 112 113 </div>

History

3 rounds 5 comments
sign up or login to add to the discussion
3 commits
expand
51141998
fix: prevent user from subscribing to own publication
d8c60bc8
feat: add Edit Publication button for owners on publication homepage
f5cdaff3
refactor: streamline LinearDocumentPage and enhance Publication layout
expand 2 comments

you have to be kidding me.

i give up. this is stressing me out.

closed without merging
2 commits
expand
51141998
fix: prevent user from subscribing to own publication
d8c60bc8
feat: add Edit Publication button for owners on publication homepage
expand 1 comment

This looks good to me! Sorry it took so long to get to reviewing it. I'm not sure if there's a way I can help resolve the merge conflicts with tangled, but if you can get those resolved we can merge!

ewancroft.uk submitted #0
1 commit
expand
51141998
fix: prevent user from subscribing to own publication
expand 2 comments

Thanks! Realized we already have this related issue - I think makes sense to replace the subscribe button with "edit publication" button linking to pub dash if you're logged in as pub creator! Mind editing to incl that? https://tangled.org/leaflet.pub/leaflet/issues/1

i'll do that soon, yeah.