🐛 Fix call notification looks broken
This commit is contained in:
parent
48c9bc21e0
commit
e15cd25c81
@ -1,6 +1,8 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
|
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
|
||||||
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
|
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
|
||||||
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
|
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
|
||||||
@ -9,7 +11,6 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var callLocks sync.Map
|
var callLocks sync.Map
|
||||||
@ -129,7 +130,7 @@ func endCall(c *fiber.Ctx) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
||||||
} else if call.FounderID != user.ID && membership.PowerLevel < 50 {
|
} else if call.FounderID != user.ID && membership.PowerLevel < 50 {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, "only call founder or channel admin can end this call")
|
return fiber.NewError(fiber.StatusBadRequest, "only call founder or channel moderator can end this call")
|
||||||
}
|
}
|
||||||
|
|
||||||
if call, err := services.EndCall(call); err != nil {
|
if call, err := services.EndCall(call); err != nil {
|
||||||
|
@ -107,7 +107,6 @@ func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call,
|
|||||||
} else if err = database.C.Where(models.ChannelMember{
|
} else if err = database.C.Where(models.ChannelMember{
|
||||||
ChannelID: call.ChannelID,
|
ChannelID: call.ChannelID,
|
||||||
}).Preload("Account").Find(&members).Error; err == nil {
|
}).Preload("Account").Find(&members).Error; err == nil {
|
||||||
channel = call.Channel
|
|
||||||
call, _ = GetCall(call.Channel, call.ID)
|
call, _ = GetCall(call.Channel, call.ID)
|
||||||
var pendingUsers []models.Account
|
var pendingUsers []models.Account
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
@ -120,11 +119,13 @@ func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel, _ = GetChannel(channel.ID)
|
||||||
|
|
||||||
err = NotifyAccountMessagerBatch(
|
err = NotifyAccountMessagerBatch(
|
||||||
pendingUsers,
|
pendingUsers,
|
||||||
&proto.NotifyRequest{
|
&proto.NotifyRequest{
|
||||||
Topic: "messaging.callStart",
|
Topic: "messaging.callStart",
|
||||||
Title: fmt.Sprintf("Call in %s", channel.DisplayText()),
|
Title: fmt.Sprintf("Call in (%s)", channel.DisplayText()),
|
||||||
Body: fmt.Sprintf("%s is calling", call.Founder.Account.Name),
|
Body: fmt.Sprintf("%s is calling", call.Founder.Account.Name),
|
||||||
Avatar: &call.Founder.Account.Avatar,
|
Avatar: &call.Founder.Account.Avatar,
|
||||||
Metadata: EncodeJSONBody(map[string]any{
|
Metadata: EncodeJSONBody(map[string]any{
|
||||||
@ -181,10 +182,7 @@ func KickParticipantInCall(call models.Call, username string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func EncodeCallToken(user models.Account, call models.Call) (string, error) {
|
func EncodeCallToken(user models.Account, call models.Call) (string, error) {
|
||||||
isAdmin := false
|
isAdmin := user.ID == call.FounderID || user.ID == call.Channel.AccountID
|
||||||
if user.ID == call.FounderID || user.ID == call.Channel.AccountID {
|
|
||||||
isAdmin = true
|
|
||||||
}
|
|
||||||
|
|
||||||
grant := &auth.VideoGrant{
|
grant := &auth.VideoGrant{
|
||||||
Room: call.ExternalID,
|
Room: call.ExternalID,
|
||||||
|
Loading…
Reference in New Issue
Block a user