✨ Meet room rendering
This commit is contained in:
parent
e21ec2e81c
commit
00ef003be9
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,4 +3,5 @@
|
|||||||
/default.etcd
|
/default.etcd
|
||||||
/keys
|
/keys
|
||||||
|
|
||||||
|
.idea
|
||||||
.DS_Store
|
.DS_Store
|
@ -12,6 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func MapControllers(app *fiber.App) {
|
func MapControllers(app *fiber.App) {
|
||||||
|
app.Get("/meet", renderMeetRoom)
|
||||||
app.Get("/captcha", renderCaptcha)
|
app.Get("/captcha", renderCaptcha)
|
||||||
app.Post("/captcha", validateCaptcha)
|
app.Post("/captcha", validateCaptcha)
|
||||||
app.Get("/check-ip", getClientIP)
|
app.Get("/check-ip", getClientIP)
|
||||||
|
55
pkg/internal/web/api/meet.go
Normal file
55
pkg/internal/web/api/meet.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type meetRoomArgs struct {
|
||||||
|
RoomName string `json:"room_name"`
|
||||||
|
User meetRoomUser `json:"user"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type meetRoomUser struct {
|
||||||
|
Avatar string `json:"avatar"`
|
||||||
|
Nick string `json:"nick"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderMeetRoom(c *fiber.Ctx) error {
|
||||||
|
if err := sec.EnsureAuthenticated(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
user := c.Locals("nex_user").(*sec.UserInfo)
|
||||||
|
|
||||||
|
channel := c.Params("channel")
|
||||||
|
|
||||||
|
var nick string
|
||||||
|
if val, ok := user.Metadata["nick"].(string); ok {
|
||||||
|
nick = val
|
||||||
|
} else {
|
||||||
|
nick = user.Name
|
||||||
|
}
|
||||||
|
var avatar string
|
||||||
|
if val, ok := user.Metadata["avatar"].(string); ok {
|
||||||
|
if strings.HasPrefix(val, "http") {
|
||||||
|
avatar = val
|
||||||
|
} else {
|
||||||
|
endpoint := viper.GetString("resources_endpoint")
|
||||||
|
avatar = fmt.Sprintf("%s/attachments/%s", endpoint, val)
|
||||||
|
}
|
||||||
|
avatar = fmt.Sprintf("\"%s\"", avatar) // Make the avatar a string to embed into the js
|
||||||
|
} else {
|
||||||
|
avatar = "undefined"
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Render("meet", meetRoomArgs{
|
||||||
|
RoomName: fmt.Sprintf("%s-%s", "sn-chat", channel),
|
||||||
|
User: meetRoomUser{
|
||||||
|
Avatar: avatar,
|
||||||
|
Nick: nick,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
@ -2,6 +2,8 @@ bind = "0.0.0.0:8001"
|
|||||||
grpc_bind = "0.0.0.0:7001"
|
grpc_bind = "0.0.0.0:7001"
|
||||||
domain = "localhost"
|
domain = "localhost"
|
||||||
|
|
||||||
|
resources_endpoint = "https://api.sn.solsynth.dev/cgi/uc"
|
||||||
|
|
||||||
templates_dir = "./templates"
|
templates_dir = "./templates"
|
||||||
ip_block_path = "./ip_block.list"
|
ip_block_path = "./ip_block.list"
|
||||||
|
|
||||||
|
78
templates/meet.tmpl
Normal file
78
templates/meet.tmpl
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Solar Network Captcha</title>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: #2d2d2d;
|
||||||
|
font-family: "Roboto Mono", monospace;
|
||||||
|
color: #c9d1d9;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
.parent {
|
||||||
|
padding: 20px;
|
||||||
|
max-width: 480px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 300;
|
||||||
|
color: #ffffff;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
margin-top: 20px;
|
||||||
|
font-size: 11px;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
.footer-product {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src='https://meet.element.io/external_api.js'></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="parent">
|
||||||
|
<div class="container" id="meet">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
function getQueryParam(name) {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
return urlParams.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const node = document.querySelector('#meet');
|
||||||
|
|
||||||
|
const domain = 'meet.element.io';
|
||||||
|
const options = {
|
||||||
|
roomName: "{{ .RoomName }}",
|
||||||
|
width: node.clientWidth,
|
||||||
|
height: node.clientHeight,
|
||||||
|
parentNode: node,
|
||||||
|
userInfo: {
|
||||||
|
avatar: {{ .User.Avatar }},
|
||||||
|
displayName: "{{ .User.Nick }}"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const api = new JitsiMeetExternalAPI(domain, options)
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user