Skip to content

Commit 81de57c

Browse files
Merge pull request #68 from HORNET-Storage/fix/image-moderation-and-react-hooks
adding updated nginx configs that include blossom route for getting m…
2 parents 55000fe + 43e3ba0 commit 81de57c

File tree

18 files changed

+422
-373
lines changed

18 files changed

+422
-373
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,43 @@ server {
209209
proxy_pass http://wallet_service;
210210
}
211211
212+
# Blossom file storage routes
213+
location /blossom/ {
214+
proxy_pass http://panel_service;
215+
proxy_set_header Host $host;
216+
proxy_set_header X-Real-IP $remote_addr;
217+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
218+
proxy_set_header X-Forwarded-Proto $scheme;
219+
220+
# Disable buffering for file uploads/downloads
221+
proxy_buffering off;
222+
proxy_request_buffering off;
223+
224+
# Set appropriate headers
225+
proxy_set_header Accept-Encoding "";
226+
227+
# Larger timeouts for file operations
228+
proxy_read_timeout 300s;
229+
proxy_send_timeout 300s;
230+
proxy_connect_timeout 60s;
231+
}
232+
212233
# Default location - Panel service (frontend + API) - MUST BE LAST
213234
location / {
235+
# Add CORS headers for the panel service
236+
add_header 'Access-Control-Allow-Origin' '*' always;
237+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
238+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always;
239+
240+
# Handle preflight OPTIONS requests
241+
if ($request_method = 'OPTIONS') {
242+
add_header 'Access-Control-Allow-Origin' '*';
243+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
244+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization';
245+
add_header 'Content-Length' 0;
246+
return 204;
247+
}
248+
214249
proxy_pass http://panel_service;
215250
proxy_set_header Host $host;
216251
proxy_set_header X-Real-IP $remote_addr;

fixed_nginx_config.conf

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,43 @@ server {
8585
proxy_pass http://wallet_service;
8686
}
8787

88+
# Blossom file storage routes
89+
location /blossom/ {
90+
proxy_pass http://panel_service;
91+
proxy_set_header Host $host;
92+
proxy_set_header X-Real-IP $remote_addr;
93+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
94+
proxy_set_header X-Forwarded-Proto $scheme;
95+
96+
# Disable buffering for file uploads/downloads
97+
proxy_buffering off;
98+
proxy_request_buffering off;
99+
100+
# Set appropriate headers
101+
proxy_set_header Accept-Encoding "";
102+
103+
# Larger timeouts for file operations
104+
proxy_read_timeout 300s;
105+
proxy_send_timeout 300s;
106+
proxy_connect_timeout 60s;
107+
}
108+
88109
# Default location - Panel service (frontend + API) - MUST BE LAST
89110
location / {
111+
# Add CORS headers for the panel service
112+
add_header 'Access-Control-Allow-Origin' '*' always;
113+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
114+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always;
115+
116+
# Handle preflight OPTIONS requests
117+
if ($request_method = 'OPTIONS') {
118+
add_header 'Access-Control-Allow-Origin' '*';
119+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
120+
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization';
121+
add_header 'Content-Length' 0;
122+
return 204;
123+
}
124+
90125
proxy_pass http://panel_service;
91126
proxy_set_header Host $host;
92127
proxy_set_header X-Real-IP $remote_addr;
@@ -98,4 +133,4 @@ server {
98133
proxy_set_header Upgrade $http_upgrade;
99134
proxy_set_header Connection $connection_upgrade;
100135
}
101-
}
136+
}

src/components/relay-settings/layouts/DesktopLayout.tsx

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import { NetworkSection } from '@app/components/relay-settings/sections/NetworkS
1212
import { KindsSection } from '@app/components/relay-settings/sections/KindsSection';
1313
import { MediaSection } from '@app/components/relay-settings/sections/MediaSection';
1414
import { ModerationSection } from '@app/components/relay-settings/sections/ModerationSection';
15+
import { CollapsibleSection } from '@app/components/relay-settings/shared/CollapsibleSection/CollapsibleSection';
16+
import { BaseSwitch } from '@app/components/common/BaseSwitch/BaseSwitch';
1517
import { useTranslation } from 'react-i18next';
1618

1719
interface DesktopLayoutProps {
18-
mode: string;
19-
onModeChange: (checked: boolean) => void;
20+
allowUnregisteredKinds: boolean;
21+
registeredKinds: number[];
22+
onAllowUnregisteredKindsChange: (allowed: boolean) => void;
2023
onSaveClick: () => void;
2124
loadings: boolean[];
2225
// Network section props
@@ -65,8 +68,9 @@ interface DesktopLayoutProps {
6568
}
6669

6770
export const DesktopLayout: React.FC<DesktopLayoutProps> = ({
68-
mode,
69-
onModeChange,
71+
allowUnregisteredKinds,
72+
registeredKinds,
73+
onAllowUnregisteredKindsChange,
7074
onSaveClick,
7175
loadings,
7276
// Network props
@@ -120,28 +124,46 @@ export const DesktopLayout: React.FC<DesktopLayoutProps> = ({
120124
</BaseRow>
121125

122126
<BaseCol xs={24}>
123-
<S.SwitchContainer
124-
style={{
125-
width: '11rem',
126-
display: 'grid',
127-
paddingTop: '3rem',
128-
gap: '.5rem',
129-
gridTemplateColumns: '1fr 3fr',
130-
marginBottom: '1.5rem',
131-
}}
132-
>
133-
<S.LabelSpan>{t('common.serverSetting')}</S.LabelSpan>
134-
<S.LargeSwitch
135-
className="modeSwitch"
136-
checkedChildren="Whitelist"
137-
unCheckedChildren="Blacklist"
138-
checked={mode === 'whitelist'}
139-
onChange={onModeChange}
140-
/>
141-
</S.SwitchContainer>
127+
<CollapsibleSection header="Allow Unregistered Kind Numbers">
128+
<S.Card>
129+
<BaseCol span={24}>
130+
<div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between' }}>
131+
<div style={{ flex: 1, marginRight: '2rem' }}>
132+
<h4 style={{ margin: '0 0 0.5rem 0', fontSize: '1rem', fontWeight: 500 }}>
133+
{t('common.allowUnregisteredKinds')}
134+
</h4>
135+
<p style={{ margin: 0, fontSize: '0.9rem', color: '#c5d3e0' }}>
136+
Enable this to allow events with kind numbers that don&apos;t have specific handlers in the relay.
137+
</p>
138+
{allowUnregisteredKinds && (
139+
<div style={{
140+
marginTop: '1rem',
141+
padding: '0.75rem 1rem',
142+
backgroundColor: 'rgba(255, 77, 79, 0.1)',
143+
borderRadius: '4px',
144+
border: '1px solid rgba(255, 77, 79, 0.3)'
145+
}}>
146+
<span style={{ color: '#ff4d4f', fontSize: '0.9rem', display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
147+
<span style={{ fontSize: '1.2rem' }}>⚠️</span>
148+
{t('common.allowUnregisteredKindsWarning')}
149+
</span>
150+
</div>
151+
)}
152+
</div>
153+
<BaseSwitch
154+
checkedChildren="ON"
155+
unCheckedChildren="OFF"
156+
checked={allowUnregisteredKinds}
157+
onChange={onAllowUnregisteredKindsChange}
158+
/>
159+
</div>
160+
</BaseCol>
161+
</S.Card>
162+
</CollapsibleSection>
142163

143164
<KindsSection
144-
mode={mode}
165+
allowUnregisteredKinds={allowUnregisteredKinds}
166+
registeredKinds={registeredKinds}
145167
isKindsActive={isKindsActive}
146168
selectedKinds={selectedKinds}
147169
dynamicKinds={dynamicKinds}
@@ -154,7 +176,6 @@ export const DesktopLayout: React.FC<DesktopLayoutProps> = ({
154176
/>
155177

156178
<MediaSection
157-
mode={mode}
158179
photos={photos}
159180
videos={videos}
160181
audio={audio}

src/components/relay-settings/layouts/MobileLayout.tsx

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import { NetworkSection } from '@app/components/relay-settings/sections/NetworkS
99
import { KindsSection } from '@app/components/relay-settings/sections/KindsSection';
1010
import { MediaSection } from '@app/components/relay-settings/sections/MediaSection';
1111
import { ModerationSection } from '@app/components/relay-settings/sections/ModerationSection';
12+
import { CollapsibleSection } from '@app/components/relay-settings/shared/CollapsibleSection/CollapsibleSection';
13+
import { BaseSwitch } from '@app/components/common/BaseSwitch/BaseSwitch';
1214
import { useTranslation } from 'react-i18next';
1315

1416
interface MobileLayoutProps {
15-
mode: string;
16-
onModeChange: (checked: boolean) => void;
17+
allowUnregisteredKinds: boolean;
18+
registeredKinds: number[];
19+
onAllowUnregisteredKindsChange: (allowed: boolean) => void;
1720
onSaveClick: () => void;
1821
loadings: boolean[];
1922
// Network section props
@@ -62,8 +65,9 @@ interface MobileLayoutProps {
6265
}
6366

6467
export const MobileLayout: React.FC<MobileLayoutProps> = ({
65-
mode,
66-
onModeChange,
68+
allowUnregisteredKinds,
69+
registeredKinds,
70+
onAllowUnregisteredKindsChange,
6771
onSaveClick,
6872
loadings,
6973
// Network props
@@ -111,27 +115,49 @@ export const MobileLayout: React.FC<MobileLayoutProps> = ({
111115
onModerationModeChange={onModerationModeChange}
112116
/>
113117

114-
<S.SwitchContainer
115-
style={{
116-
display: 'grid',
117-
paddingTop: '2rem',
118-
gridTemplateColumns: '5rem 6.5rem',
119-
marginBottom: '1.5rem',
120-
marginTop: '1rem',
121-
}}
122-
>
123-
<S.LabelSpan>{t('common.serverSetting')}</S.LabelSpan>
124-
<S.LargeSwitch
125-
className="modeSwitch"
126-
checkedChildren="Whitelist"
127-
unCheckedChildren="Blacklist"
128-
checked={mode === 'whitelist'}
129-
onChange={onModeChange}
130-
/>
131-
</S.SwitchContainer>
118+
<CollapsibleSection header="Allow Unregistered Kind Numbers">
119+
<S.Card>
120+
<BaseCol span={24}>
121+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
122+
<div>
123+
<h4 style={{ margin: '0 0 0.5rem 0', fontSize: '1rem', fontWeight: 500 }}>
124+
{t('common.allowUnregisteredKinds')}
125+
</h4>
126+
<p style={{ margin: 0, fontSize: '0.85rem', color: '#c5d3e0' }}>
127+
Enable this to allow events with kind numbers that don&apos;t have specific handlers in the relay.
128+
</p>
129+
</div>
130+
131+
<div style={{ display: 'flex', justifyContent: 'flex-start' }}>
132+
<BaseSwitch
133+
checkedChildren="ON"
134+
unCheckedChildren="OFF"
135+
checked={allowUnregisteredKinds}
136+
onChange={onAllowUnregisteredKindsChange}
137+
/>
138+
</div>
139+
140+
{allowUnregisteredKinds && (
141+
<div style={{
142+
padding: '0.75rem',
143+
backgroundColor: 'rgba(255, 77, 79, 0.1)',
144+
borderRadius: '4px',
145+
border: '1px solid rgba(255, 77, 79, 0.3)'
146+
}}>
147+
<span style={{ color: '#ff4d4f', fontSize: '0.85rem', display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
148+
<span style={{ fontSize: '1.1rem' }}>⚠️</span>
149+
{t('common.allowUnregisteredKindsWarning')}
150+
</span>
151+
</div>
152+
)}
153+
</div>
154+
</BaseCol>
155+
</S.Card>
156+
</CollapsibleSection>
132157

133158
<KindsSection
134-
mode={mode}
159+
allowUnregisteredKinds={allowUnregisteredKinds}
160+
registeredKinds={registeredKinds}
135161
isKindsActive={isKindsActive}
136162
selectedKinds={selectedKinds}
137163
dynamicKinds={dynamicKinds}
@@ -144,7 +170,6 @@ export const MobileLayout: React.FC<MobileLayoutProps> = ({
144170
/>
145171

146172
<MediaSection
147-
mode={mode}
148173
photos={photos}
149174
videos={videos}
150175
audio={audio}

src/components/relay-settings/sections/KindsSection/KindsSection.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { AddKindForm } from './components/AddKindForm';
99
import { DynamicKindsList } from './components/DynamicKindsList';
1010

1111
export interface KindsSectionProps {
12-
mode: string;
12+
allowUnregisteredKinds: boolean;
13+
registeredKinds: number[];
1314
isKindsActive: boolean;
1415
selectedKinds: string[];
1516
dynamicKinds: string[];
@@ -22,7 +23,8 @@ export interface KindsSectionProps {
2223
}
2324

2425
export const KindsSection: React.FC<KindsSectionProps> = ({
25-
mode,
26+
allowUnregisteredKinds,
27+
registeredKinds,
2628
isKindsActive,
2729
selectedKinds,
2830
dynamicKinds,
@@ -33,37 +35,34 @@ export const KindsSection: React.FC<KindsSectionProps> = ({
3335
onAddKind,
3436
onRemoveKind,
3537
}) => {
36-
const header = mode !== 'whitelist' ? 'Blacklisted Kind Numbers' : 'Kind Numbers';
38+
const header = 'Event Kinds Configuration';
3739

3840
return (
3941
<CollapsibleSection header={header}>
4042
<S.Card>
4143
<div className="flex-col w-full">
42-
{mode !== 'blacklist' && mode !== '' && (
43-
<div className="switch-container">
44-
<BaseSwitch
45-
checkedChildren="ON"
46-
unCheckedChildren="OFF"
47-
checked={isKindsActive}
48-
onChange={() => onKindsActiveChange(!isKindsActive)}
49-
/>
50-
</div>
51-
)}
44+
<div className="switch-container">
45+
<BaseSwitch
46+
checkedChildren="ON"
47+
unCheckedChildren="OFF"
48+
checked={isKindsActive}
49+
onChange={() => onKindsActiveChange(!isKindsActive)}
50+
/>
51+
</div>
5252

5353
<KindsList
54-
mode={mode}
5554
selectedKinds={selectedKinds}
5655
isKindsActive={isKindsActive}
5756
onKindsChange={onKindsChange}
5857
/>
5958

60-
<AddKindForm
61-
mode={mode}
59+
<AddKindForm
6260
onAddKind={onAddKind}
6361
/>
6462

6563
<DynamicKindsList
66-
mode={mode}
64+
allowUnregisteredKinds={allowUnregisteredKinds}
65+
registeredKinds={registeredKinds}
6766
dynamicKinds={dynamicKinds}
6867
selectedDynamicKinds={selectedDynamicKinds}
6968
onDynamicKindsChange={onDynamicKindsChange}

src/components/relay-settings/sections/KindsSection/components/AddKindForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { BaseButton } from '@app/components/common/BaseButton/BaseButton';
66

77
interface AddKindFormProps {
88
onAddKind: (kind: string) => void;
9-
mode: string;
109
}
1110

12-
export const AddKindForm: React.FC<AddKindFormProps> = ({ onAddKind, mode }) => {
11+
export const AddKindForm: React.FC<AddKindFormProps> = ({ onAddKind }) => {
1312
const [newKind, setNewKind] = useState('');
1413

1514
const handleAddKind = () => {
@@ -23,7 +22,7 @@ export const AddKindForm: React.FC<AddKindFormProps> = ({ onAddKind, mode }) =>
2322

2423
return (
2524
<div style={{ padding: '1.5rem 0rem 0rem 0rem', display: 'flex', flexDirection: 'column', gap: '.5rem' }}>
26-
<h3>{mode === 'blacklist' ? 'Add Custom Kind to Whitelist' : 'Add Custom Kind'}</h3>
25+
<h3>Add Custom Kind</h3>
2726
<div style={{ display: 'flex' }} className="custom-checkbox-group grid-checkbox-group large-label">
2827
<Input
2928
value={newKind}

0 commit comments

Comments
 (0)