🐛 Fix notify and others
This commit is contained in:
parent
476466f8c6
commit
50f2d88abc
@ -130,7 +130,7 @@ func exchangeCallToken(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
tk, err := services.EncodeCallToken(call, user)
|
tk, err := services.EncodeCallToken(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,12 +83,13 @@ 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)
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
if member.ID != call.Founder.ID {
|
if member.ID != call.Founder.ID {
|
||||||
if member.Notify == models.NotifyLevelAll {
|
if member.Notify == models.NotifyLevelAll {
|
||||||
err = NotifyAccount(member.Account,
|
err = NotifyAccount(member.Account,
|
||||||
fmt.Sprintf("New Call #%s", call.Channel.Alias),
|
fmt.Sprintf("New Call #%s", channel.Alias),
|
||||||
fmt.Sprintf("%s starts a new call", call.Founder.Account.Name),
|
fmt.Sprintf("%s starts a new call", call.Founder.Account.Name),
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
@ -128,7 +129,7 @@ func EndCall(call models.Call) (models.Call, error) {
|
|||||||
return call, nil
|
return call, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func EncodeCallToken(call models.Call, user models.Account) (string, error) {
|
func EncodeCallToken(user models.Account) (string, error) {
|
||||||
// Jitsi requires HS256 as algorithm, so we cannot use HS512
|
// Jitsi requires HS256 as algorithm, so we cannot use HS512
|
||||||
tk := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
|
tk := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
|
||||||
"context": jwt.MapClaims{
|
"context": jwt.MapClaims{
|
||||||
@ -140,7 +141,7 @@ func EncodeCallToken(call models.Call, user models.Account) (string, error) {
|
|||||||
"aud": viper.GetString("meeting.client_id"),
|
"aud": viper.GetString("meeting.client_id"),
|
||||||
"iss": viper.GetString("domain"),
|
"iss": viper.GetString("domain"),
|
||||||
"sub": "meet.jitsi",
|
"sub": "meet.jitsi",
|
||||||
"room": call.ExternalID,
|
"room": "*",
|
||||||
})
|
})
|
||||||
|
|
||||||
return tk.SignedString([]byte(viper.GetString("meeting.client_secret")))
|
return tk.SignedString([]byte(viper.GetString("meeting.client_secret")))
|
||||||
|
@ -82,13 +82,14 @@ func NewMessage(message models.Message) (models.Message, error) {
|
|||||||
} else if err = database.C.Where(models.ChannelMember{
|
} else if err = database.C.Where(models.ChannelMember{
|
||||||
ChannelID: message.ChannelID,
|
ChannelID: message.ChannelID,
|
||||||
}).Preload("Account").Find(&members).Error; err == nil {
|
}).Preload("Account").Find(&members).Error; err == nil {
|
||||||
for _, member := range members {
|
channel := message.Channel
|
||||||
message, _ = GetMessage(message.Channel, message.ID)
|
message, _ = GetMessage(message.Channel, message.ID)
|
||||||
|
for _, member := range members {
|
||||||
if member.ID != message.Sender.ID {
|
if member.ID != message.Sender.ID {
|
||||||
// TODO Check the mentioned status
|
// TODO Check the mentioned status
|
||||||
if member.Notify == models.NotifyLevelAll {
|
if member.Notify == models.NotifyLevelAll {
|
||||||
err = NotifyAccount(member.Account,
|
err = NotifyAccount(member.Account,
|
||||||
fmt.Sprintf("New Message #%s", message.Channel.Alias),
|
fmt.Sprintf("New Message #%s", channel.Alias),
|
||||||
fmt.Sprintf("%s: %s", message.Sender.Account.Name, message.Content),
|
fmt.Sprintf("%s: %s", message.Sender.Account.Name, message.Content),
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user