Make verified groups optional

DC verified groups stopped working for a while, so it seemed like a good idea to make the
use of this feature optional. A new (boolean) config value called verified_groups has been
added.
master
Hugo Thunnissen 4 years ago
parent 4967c423c2
commit e5300cdfb9

@ -1,6 +1,8 @@
package core
import (
"log"
"github.com/Rhymen/go-whatsapp"
"github.com/hugot/go-deltachat/deltabot"
"github.com/hugot/go-deltachat/deltachat"
@ -46,6 +48,7 @@ func (b *BridgeContext) Init(
}
for i := 0; i < 10; i++ {
log.Println("Attempting whapp login")
err = CreateAndLoginWhappConnection(b.Config.App.DataFolder, b)
if err == nil {

@ -7,9 +7,10 @@ import (
)
type AppConfig struct {
DataFolder string `yaml:"data_folder"`
UserAddress string `yaml:"user"`
ShowFromMe bool `yaml:"show_from_me"`
DataFolder string `yaml:"data_folder"`
UserAddress string `yaml:"user"`
ShowFromMe bool `yaml:"show_from_me"`
VerifiedGroups bool `yaml:"verified_groups"`
}
type Config struct {

@ -56,32 +56,39 @@ func BootstrapDcClientFromConfig(config Config, ctx *BridgeContext) (*deltachat.
userName := "user"
dcUserID := DCCtx.CreateContact(&userName, &config.App.UserAddress)
// Send a message in a 1:1 chat first, this will let the user's client know that the
// crypto setup has changed if it has
DCCtx.SendTextMessage(
DCCtx.CreateChatByContactID(dcUserID),
"Hi, Whapp-Deltachat is initializing",
)
userChatIDRaw := ctx.DB.Get([]byte("user-chat-id"))
var (
userChatID uint32
err error
)
if userChatIDRaw == nil {
userChatID, err = AddUserAsVerifiedContact(dcUserID, dcClient)
if err != nil {
return nil, err
if config.App.VerifiedGroups {
// Send a message in a 1:1 chat first, this will let the user's client know that the
// crypto setup has changed if it has
DCCtx.SendTextMessage(
DCCtx.CreateChatByContactID(dcUserID),
"Hi, Whapp-Deltachat is initializing",
)
userChatIDRaw := ctx.DB.Get([]byte("user-chat-id"))
// The verified group chat that is used as 1:1 between whappDC and the user is
// created here if verified groups are enabled.
if userChatIDRaw == nil {
userChatID, err = AddUserAsVerifiedContact(dcUserID, dcClient)
if err != nil {
return nil, err
}
} else {
userChatID = binary.LittleEndian.Uint32(userChatIDRaw)
}
userChatIDbs := make([]byte, 4)
binary.LittleEndian.PutUint32(userChatIDbs, userChatID)
err = ctx.DB.Put([]byte("user-chat-id"), userChatIDbs)
} else {
userChatID = binary.LittleEndian.Uint32(userChatIDRaw)
userChatID = DCCtx.CreateChatByContactID(dcUserID)
}
userChatIDbs := make([]byte, 4)
binary.LittleEndian.PutUint32(userChatIDbs, userChatID)
err = ctx.DB.Put([]byte("user-chat-id"), userChatIDbs)
ctx.DCUserID = dcUserID
ctx.DCUserChatID = userChatID
ctx.DCContext = DCCtx

@ -48,7 +48,7 @@ func (w *WhappContext) GetOrCreateDCIDForJID(JID string) (uint32, error) {
chatName = sender.Name
}
DCID := w.BridgeCtx.DCContext.CreateGroupChat(true, chatName)
DCID := w.BridgeCtx.DCContext.CreateGroupChat(w.BridgeCtx.Config.App.VerifiedGroups, chatName)
err := w.BridgeCtx.DB.StoreDCIDForJID(JID, DCID)

Loading…
Cancel
Save