mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-11-05 22:38:54 +01:00
Don't sleep for 5 seconds when creating portal for join via link
This commit is contained in:
parent
7c33ed04c4
commit
5c5633548f
2 changed files with 10 additions and 2 deletions
|
@ -566,6 +566,12 @@ func (prov *ProvisioningAPI) JoinGroup(w http.ResponseWriter, r *http.Request) {
|
|||
if info == nil {
|
||||
return
|
||||
}
|
||||
user.groupJoinLock.Lock()
|
||||
user.skipGroupCreateDelay = info.JID
|
||||
defer func() {
|
||||
user.skipGroupCreateDelay = types.EmptyJID
|
||||
user.groupJoinLock.Unlock()
|
||||
}()
|
||||
inviteCode, _ := mux.Vars(r)["inviteCode"]
|
||||
if jid, err := user.Client.JoinGroupWithLink(inviteCode); err != nil {
|
||||
jsonResponse(w, http.StatusInternalServerError, Error{
|
||||
|
|
6
user.go
6
user.go
|
@ -95,7 +95,9 @@ type User struct {
|
|||
resyncQueueLock sync.Mutex
|
||||
nextResync time.Time
|
||||
|
||||
createKeyDedup string
|
||||
createKeyDedup string
|
||||
skipGroupCreateDelay types.JID
|
||||
groupJoinLock sync.Mutex
|
||||
}
|
||||
|
||||
type resyncQueueItem struct {
|
||||
|
@ -1304,7 +1306,7 @@ func (user *User) markUnread(portal *Portal, unread bool) {
|
|||
|
||||
func (user *User) handleGroupCreate(evt *events.JoinedGroup) {
|
||||
portal := user.GetPortalByJID(evt.JID)
|
||||
if evt.CreateKey == "" && len(portal.MXID) == 0 {
|
||||
if evt.CreateKey == "" && len(portal.MXID) == 0 && portal.Key.JID != user.skipGroupCreateDelay {
|
||||
user.log.Debugfln("Delaying handling group create with empty key to avoid race conditions")
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue