Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
-- acomodar layout corretamente no mobile
-- tema escuro
-- temas diferenciados por ex. vaporwave/synthwave
- Emoticon
-- Digitação "flúida"
- Kaomoji/caules
- Permitir citar/responder
- Menu de opções
- Métricas com grafana
- Mostrar infos em tempo real por ex. usuários online
- Métricas com grafana/prometheus
- Múltiplos chats
- mudar domínio para 'chat.gustavoqueiroz.dev'
- Filtrar spam
- Permitir bloquear IP
- Visão admin
- Shader/3D/firulas
- Shader/3D/firulas
- Localização/idioma
- Performance Pagespeed
- Arrumar portas do docker
4 changes: 2 additions & 2 deletions backend/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Cors": {
"AllowedOrigins": [ "https://gustavoqueiroz.dev" ]
"AllowedOrigins": [ "https://chat.gustavoqueiroz.dev" ]
},
"AllowedHosts": "gustavoqueiroz.dev;www.gustavoqueiroz.dev"
"AllowedHosts": "chat.gustavoqueiroz.dev"
}
5 changes: 2 additions & 3 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ services:
context: .
ports: !reset []
expose:
- "8080"
- "2001"

frontend:
image: guessst/chat-frontend:latest
build:
context: .
ports:
- "80:80"
- "443:443"
- "2000:2000"
volumes:
- /etc/letsencrypt:/etc/letsencrypt:ro
- /var/www/certbot:/usr/share/nginx/html/.well-known/acme-challenge
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ services:
ENV_POSTGRES_PASSWORD: ${ENV_POSTGRES_PASSWORD}
ASPNETCORE_ENVIRONMENT: ${ENV_ASPNETCORE_ENVIRONMENT}
ports:
- "8080:8080"
- "2001:2001"

frontend:
build: ./frontend
depends_on:
- backend
ports:
- "80:80"
- "2000:2000"

volumes:
db_data:
Expand Down
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Projeto</title>
<title>Chat</title>
<link rel="icon" type="image/png" href="favicon-min.png" />
<link href="./src/index.css" rel="stylesheet">
</head>
Expand Down
19 changes: 4 additions & 15 deletions frontend/nginx.production.conf
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
server {
listen 80;
server_name gustavoqueiroz.dev www.gustavoqueiroz.dev;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name gustavoqueiroz.dev www.gustavoqueiroz.dev;

ssl_certificate /etc/letsencrypt/live/gustavoqueiroz.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gustavoqueiroz.dev/privkey.pem;

listen 2000;

root /usr/share/nginx/html;

index index.html;

location / {
try_files $uri $uri/ /index.html;
}

location /chat {
proxy_pass http://backend:8080;
proxy_pass http://backend:2001;
proxy_set_header Host $host;
}

location /chatHub {
proxy_pass http://backend:8080;
proxy_pass http://backend:2001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Expand Down
Binary file modified frontend/public/favicon-min.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 41 additions & 4 deletions frontend/src/ChatHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { SettingsDialog } from "./SettingsDialog";

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

// const IS_DEV = import.meta.env.DEV === true

interface ChatMessage {
id: number
username: string
Expand Down Expand Up @@ -56,6 +54,32 @@ function useLocalStorage(key: string, initialValue: string) {
return [value, setValue] as const;
}

function getMilisecondsUntilBrazilianMidnight() {
const now = new Date();

// current UTC time in ms
const nowUtc = now.getTime() + now.getTimezoneOffset() * 60_000;

// offset for Brazil (UTC−3)
const brazilOffsetMs = -3 * 60 * 60 * 1000;

// current "Brazil time"
const nowBrazil = new Date(nowUtc + brazilOffsetMs);

// next midnight in Brazil
const nextMidnightBrazil = new Date(nowBrazil);
nextMidnightBrazil.setHours(24, 0, 0, 0);

// convert that Brazil midnight back to UTC
const nextMidnightUtc =
nextMidnightBrazil.getTime() - brazilOffsetMs;

// how long until then from now
const msUntilMidnight = nextMidnightUtc - nowUtc;

return msUntilMidnight
}

const MessageItem = ({ formattedMessage }: { formattedMessage: FormattedChatMessage }) => {
return (
<div key={formattedMessage.id} className="p-2 text-gray-800 w-full">
Expand Down Expand Up @@ -273,6 +297,16 @@ export const ChatHub = () => {
}
}, [currentInput]); // runs whenever input changes

// MISCELANEOUS
useEffect(() => {
const msUntilMidnight = getMilisecondsUntilBrazilianMidnight()
const timer = setTimeout(() => {
window.location.reload();
}, msUntilMidnight);

return () => clearTimeout(timer);
}, [])


return (
<div>
Expand Down Expand Up @@ -331,8 +365,6 @@ export const ChatHub = () => {
/>
<Emojis insertAtCursor={insertAtCursor} ></Emojis>
</div>

{/* <CustomSnippetsInput></CustomSnippetsInput> */}
<button
onClick={handleSendMessage}
className="w-12 h-12 rounded-full bg-blue-500 text-white flex items-center justify-center hover:bg-blue-600 hover:cursor-pointer"
Expand All @@ -343,6 +375,11 @@ export const ChatHub = () => {
</div>
</div>
</div>
<footer className="py-4">
<div className="max-w-7xl mx-auto px-4 text-center text-sm text-amber-600">
⚠️ The Chat™ resets every day at midnight Brazilian Time (UTC -3).
</div>
</footer>
</div>
);
}