-
Notifications
You must be signed in to change notification settings - Fork 2
/
vkGroup.go
28 lines (23 loc) · 891 Bytes
/
vkGroup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package repos
import (
"log"
"gopkg.in/mgo.v2/bson"
"github.com/khades/servbot/models"
)
func PushVkGroupInfo(channelID *string, vkGroupInfo *models.VkGroupInfo) {
log.Println("pushing info")
log.Println(*channelID)
log.Println(*vkGroupInfo)
channelInfo, _ := GetChannelInfo(channelID)
if channelInfo != nil {
channelInfo.VkGroupInfo = *vkGroupInfo
} else {
channelInfoRepositoryObject.forceCreateObject(*channelID, &models.ChannelInfo{ChannelID: *channelID, VkGroupInfo: *vkGroupInfo})
}
Db.C(channelInfoCollection).Upsert(models.ChannelSelector{ChannelID: *channelID}, bson.M{"$set": bson.M{"vkgroupinfo": *vkGroupInfo}})
}
func GetVKEnabledChannels() (*[]models.ChannelInfo, error) {
result := []models.ChannelInfo{}
error := Db.C(channelInfoCollection).Find(bson.M{"vkgroupinfo.groupname": bson.M{"$exists": true, "$ne": ""}}).All(&result)
return &result, error
}