Skip to content

Commit 4bffef5

Browse files
authored
Merge pull request #3 from Guessst/develop
Domain change, reset timer
2 parents 09a40eb + 68d9086 commit 4bffef5

8 files changed

Lines changed: 61 additions & 31 deletions

File tree

TODO.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
-- acomodar layout corretamente no mobile
33
-- tema escuro
44
-- temas diferenciados por ex. vaporwave/synthwave
5-
- Emoticon
5+
-- Digitação "flúida"
6+
- Kaomoji/caules
67
- Permitir citar/responder
7-
- Menu de opções
8-
- Métricas com grafana
8+
- Mostrar infos em tempo real por ex. usuários online
9+
- Métricas com grafana/prometheus
910
- Múltiplos chats
11+
- mudar domínio para 'chat.gustavoqueiroz.dev'
1012
- Filtrar spam
1113
- Permitir bloquear IP
1214
- Visão admin
13-
- Shader/3D/firulas
15+
- Shader/3D/firulas
16+
- Localização/idioma
17+
- Performance Pagespeed
18+
- Arrumar portas do docker
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Cors": {
3-
"AllowedOrigins": [ "https://gustavoqueiroz.dev" ]
3+
"AllowedOrigins": [ "https://chat.gustavoqueiroz.dev" ]
44
},
5-
"AllowedHosts": "gustavoqueiroz.dev;www.gustavoqueiroz.dev"
5+
"AllowedHosts": "chat.gustavoqueiroz.dev"
66
}

docker-compose.production.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ services:
1111
context: .
1212
ports: !reset []
1313
expose:
14-
- "8080"
14+
- "2001"
1515

1616
frontend:
1717
image: guessst/chat-frontend:latest
1818
build:
1919
context: .
2020
ports:
21-
- "80:80"
22-
- "443:443"
21+
- "2000:2000"
2322
volumes:
2423
- /etc/letsencrypt:/etc/letsencrypt:ro
2524
- /var/www/certbot:/usr/share/nginx/html/.well-known/acme-challenge

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ services:
4545
ENV_POSTGRES_PASSWORD: ${ENV_POSTGRES_PASSWORD}
4646
ASPNETCORE_ENVIRONMENT: ${ENV_ASPNETCORE_ENVIRONMENT}
4747
ports:
48-
- "8080:8080"
48+
- "2001:2001"
4949

5050
frontend:
5151
build: ./frontend
5252
depends_on:
5353
- backend
5454
ports:
55-
- "80:80"
55+
- "2000:2000"
5656

5757
volumes:
5858
db_data:

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Projeto</title>
6+
<title>Chat</title>
77
<link rel="icon" type="image/png" href="favicon-min.png" />
88
<link href="./src/index.css" rel="stylesheet">
99
</head>

frontend/nginx.production.conf

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
server {
2-
listen 80;
3-
server_name gustavoqueiroz.dev www.gustavoqueiroz.dev;
4-
return 301 https://$host$request_uri;
5-
}
6-
7-
server {
8-
listen 443 ssl;
9-
server_name gustavoqueiroz.dev www.gustavoqueiroz.dev;
10-
11-
ssl_certificate /etc/letsencrypt/live/gustavoqueiroz.dev/fullchain.pem;
12-
ssl_certificate_key /etc/letsencrypt/live/gustavoqueiroz.dev/privkey.pem;
13-
2+
listen 2000;
3+
144
root /usr/share/nginx/html;
15-
165
index index.html;
176

187
location / {
198
try_files $uri $uri/ /index.html;
209
}
2110

2211
location /chat {
23-
proxy_pass http://backend:8080;
12+
proxy_pass http://backend:2001;
2413
proxy_set_header Host $host;
2514
}
2615

2716
location /chatHub {
28-
proxy_pass http://backend:8080;
17+
proxy_pass http://backend:2001;
2918
proxy_http_version 1.1;
3019
proxy_set_header Upgrade $http_upgrade;
3120
proxy_set_header Connection "upgrade";

frontend/public/favicon-min.png

976 Bytes
Loading

frontend/src/ChatHub.tsx

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { SettingsDialog } from "./SettingsDialog";
88

99
const USER_LOCALE = navigator.language || navigator.languages[0];
1010

11-
// const IS_DEV = import.meta.env.DEV === true
12-
1311
interface ChatMessage {
1412
id: number
1513
username: string
@@ -56,6 +54,32 @@ function useLocalStorage(key: string, initialValue: string) {
5654
return [value, setValue] as const;
5755
}
5856

57+
function getMilisecondsUntilBrazilianMidnight() {
58+
const now = new Date();
59+
60+
// current UTC time in ms
61+
const nowUtc = now.getTime() + now.getTimezoneOffset() * 60_000;
62+
63+
// offset for Brazil (UTC−3)
64+
const brazilOffsetMs = -3 * 60 * 60 * 1000;
65+
66+
// current "Brazil time"
67+
const nowBrazil = new Date(nowUtc + brazilOffsetMs);
68+
69+
// next midnight in Brazil
70+
const nextMidnightBrazil = new Date(nowBrazil);
71+
nextMidnightBrazil.setHours(24, 0, 0, 0);
72+
73+
// convert that Brazil midnight back to UTC
74+
const nextMidnightUtc =
75+
nextMidnightBrazil.getTime() - brazilOffsetMs;
76+
77+
// how long until then from now
78+
const msUntilMidnight = nextMidnightUtc - nowUtc;
79+
80+
return msUntilMidnight
81+
}
82+
5983
const MessageItem = ({ formattedMessage }: { formattedMessage: FormattedChatMessage }) => {
6084
return (
6185
<div key={formattedMessage.id} className="p-2 text-gray-800 w-full">
@@ -273,6 +297,16 @@ export const ChatHub = () => {
273297
}
274298
}, [currentInput]); // runs whenever input changes
275299

300+
// MISCELANEOUS
301+
useEffect(() => {
302+
const msUntilMidnight = getMilisecondsUntilBrazilianMidnight()
303+
const timer = setTimeout(() => {
304+
window.location.reload();
305+
}, msUntilMidnight);
306+
307+
return () => clearTimeout(timer);
308+
}, [])
309+
276310

277311
return (
278312
<div>
@@ -331,8 +365,6 @@ export const ChatHub = () => {
331365
/>
332366
<Emojis insertAtCursor={insertAtCursor} ></Emojis>
333367
</div>
334-
335-
{/* <CustomSnippetsInput></CustomSnippetsInput> */}
336368
<button
337369
onClick={handleSendMessage}
338370
className="w-12 h-12 rounded-full bg-blue-500 text-white flex items-center justify-center hover:bg-blue-600 hover:cursor-pointer"
@@ -343,6 +375,11 @@ export const ChatHub = () => {
343375
</div>
344376
</div>
345377
</div>
378+
<footer className="py-4">
379+
<div className="max-w-7xl mx-auto px-4 text-center text-sm text-amber-600">
380+
⚠️ The Chat™ resets every day at midnight Brazilian Time (UTC -3).
381+
</div>
382+
</footer>
346383
</div>
347384
);
348385
}

0 commit comments

Comments
 (0)