2022-01-21 00:26:59 +00:00
|
|
|
package databag
|
|
|
|
|
|
|
|
import (
|
|
|
|
"databag/internal/store"
|
|
|
|
)
|
|
|
|
|
2022-02-09 18:30:39 +00:00
|
|
|
func getProfileModel(account *store.Account) *Profile {
|
|
|
|
|
|
|
|
return &Profile{
|
|
|
|
Guid: account.Guid,
|
|
|
|
Handle: account.Username,
|
|
|
|
Description: account.AccountDetail.Description,
|
|
|
|
Location: account.AccountDetail.Location,
|
|
|
|
Image: account.AccountDetail.Image,
|
|
|
|
Revision: account.ProfileRevision,
|
|
|
|
Version: APP_VERSION,
|
|
|
|
Node: "https://" + getStrConfigValue(CONFIG_DOMAIN, "") + "/",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 06:13:46 +00:00
|
|
|
func getCardModel(slot *store.CardSlot) *Card {
|
|
|
|
|
|
|
|
if slot.Card == nil {
|
|
|
|
return &Card{
|
2022-02-08 20:24:42 +00:00
|
|
|
Id: slot.CardSlotId,
|
2022-02-04 21:26:52 +00:00
|
|
|
Revision: slot.Revision,
|
2022-02-03 06:13:46 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-21 00:26:59 +00:00
|
|
|
|
|
|
|
return &Card{
|
2022-02-08 20:24:42 +00:00
|
|
|
Id: slot.CardSlotId,
|
2022-02-03 20:11:51 +00:00
|
|
|
Revision: slot.Revision,
|
2022-02-08 20:24:42 +00:00
|
|
|
Data: &CardData {
|
2022-02-03 06:13:46 +00:00
|
|
|
NotifiedProfile: slot.Card.NotifiedProfile,
|
2022-02-08 20:24:42 +00:00
|
|
|
NotifiedArticle: slot.Card.NotifiedArticle,
|
|
|
|
NotifiedChannel: slot.Card.NotifiedChannel,
|
|
|
|
NotifiedView: slot.Card.NotifiedView,
|
|
|
|
ProfileRevision: slot.Card.ProfileRevision,
|
|
|
|
DetailRevision: slot.Card.DetailRevision,
|
|
|
|
CardDetail: getCardDetailModel(slot),
|
|
|
|
CardProfile: getCardProfileModel(slot),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getCardRevisionModel(slot *store.CardSlot) *Card {
|
|
|
|
|
|
|
|
if slot.Card == nil {
|
|
|
|
return &Card{
|
|
|
|
Id: slot.CardSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Card{
|
|
|
|
Id: slot.CardSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
Data: &CardData {
|
|
|
|
NotifiedProfile: slot.Card.NotifiedProfile,
|
|
|
|
NotifiedArticle: slot.Card.NotifiedArticle,
|
|
|
|
NotifiedChannel: slot.Card.NotifiedChannel,
|
2022-02-03 06:13:46 +00:00
|
|
|
NotifiedView: slot.Card.NotifiedView,
|
2022-02-03 21:34:03 +00:00
|
|
|
ProfileRevision: slot.Card.ProfileRevision,
|
|
|
|
DetailRevision: slot.Card.DetailRevision,
|
2022-01-21 00:26:59 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:34:03 +00:00
|
|
|
func getCardDetailModel(slot *store.CardSlot) *CardDetail {
|
|
|
|
|
|
|
|
var groups []string;
|
|
|
|
for _, group := range slot.Card.Groups {
|
|
|
|
groups = append(groups, group.GroupSlot.GroupSlotId)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &CardDetail{
|
2022-02-08 20:24:42 +00:00
|
|
|
Status: slot.Card.Status,
|
|
|
|
Token: slot.Card.OutToken,
|
2022-02-03 21:34:03 +00:00
|
|
|
Notes: slot.Card.Notes,
|
|
|
|
Groups: groups,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getCardProfileModel(slot *store.CardSlot) *CardProfile {
|
|
|
|
|
|
|
|
return &CardProfile{
|
2022-02-08 20:24:42 +00:00
|
|
|
Guid: slot.Card.Guid,
|
2022-02-03 21:34:03 +00:00
|
|
|
Handle: slot.Card.Username,
|
|
|
|
Name: slot.Card.Name,
|
|
|
|
Description: slot.Card.Description,
|
|
|
|
Location: slot.Card.Location,
|
|
|
|
ImageSet: slot.Card.Image != "",
|
|
|
|
Version: slot.Card.Version,
|
|
|
|
Node: slot.Card.Node,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 07:48:17 +00:00
|
|
|
func getGroupModel(slot *store.GroupSlot) *Group {
|
|
|
|
if slot.Group == nil {
|
|
|
|
return &Group{
|
2022-02-08 20:24:42 +00:00
|
|
|
Id: slot.GroupSlotId,
|
2022-02-04 21:26:52 +00:00
|
|
|
Revision: slot.Revision,
|
2022-02-03 07:48:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 05:22:33 +00:00
|
|
|
return &Group{
|
2022-02-08 20:24:42 +00:00
|
|
|
Id: slot.GroupSlotId,
|
2022-02-03 20:11:51 +00:00
|
|
|
Revision: slot.Revision,
|
2022-02-08 20:24:42 +00:00
|
|
|
Data: &GroupData {
|
2022-02-03 07:48:17 +00:00
|
|
|
DataType: slot.Group.DataType,
|
|
|
|
Data: slot.Group.GroupData.Data,
|
|
|
|
Created: slot.Group.Created,
|
|
|
|
Updated: slot.Group.Updated,
|
|
|
|
},
|
2022-01-25 05:22:33 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-28 07:01:17 +00:00
|
|
|
|
2022-02-14 20:55:02 +00:00
|
|
|
func getArticleModel(slot *store.ArticleSlot, showData bool, showGroups bool) *Article {
|
|
|
|
if !showData || slot.Article == nil {
|
2022-02-13 07:29:40 +00:00
|
|
|
return &Article{
|
|
|
|
Id: slot.ArticleSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var articleGroups *ArticleGroups
|
|
|
|
if showGroups {
|
|
|
|
var groups []string;
|
|
|
|
for _, group := range slot.Article.Groups {
|
|
|
|
groups = append(groups, group.GroupSlot.GroupSlotId)
|
|
|
|
}
|
|
|
|
articleGroups = &ArticleGroups{ Groups: groups }
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Article{
|
|
|
|
Id: slot.ArticleSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
Data: &ArticleData {
|
|
|
|
DataType: slot.Article.DataType,
|
|
|
|
Data: slot.Article.Data,
|
|
|
|
Created: slot.Article.Created,
|
|
|
|
Updated: slot.Article.Updated,
|
|
|
|
Groups: articleGroups,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 22:30:04 +00:00
|
|
|
func getChannelRevisionModel(slot *store.ChannelSlot, showData bool, showGroups bool) *Channel {
|
|
|
|
|
|
|
|
if !showData || slot.Channel == nil {
|
|
|
|
return &Channel{
|
|
|
|
Id: slot.ChannelSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Channel{
|
|
|
|
Id: slot.ChannelSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
Data: &ChannelData {
|
|
|
|
DetailRevision: slot.Channel.DetailRevision,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getChannelModel(slot *store.ChannelSlot, showData bool, showGroups bool) *Channel {
|
|
|
|
|
|
|
|
if !showData || slot.Channel == nil {
|
|
|
|
return &Channel{
|
|
|
|
Id: slot.ChannelSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var channelGroups *ChannelGroups
|
|
|
|
if showGroups {
|
|
|
|
var groups []string;
|
|
|
|
for _, group := range slot.Channel.Groups {
|
|
|
|
groups = append(groups, group.GroupSlot.GroupSlotId)
|
|
|
|
}
|
|
|
|
channelGroups = &ChannelGroups{ Groups: groups }
|
|
|
|
}
|
|
|
|
|
|
|
|
var cards []string
|
|
|
|
for _, card := range slot.Channel.Cards {
|
|
|
|
cards = append(cards, card.CardSlot.CardSlotId)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Channel{
|
|
|
|
Id: slot.ChannelSlotId,
|
|
|
|
Revision: slot.Revision,
|
|
|
|
Data: &ChannelData {
|
|
|
|
DetailRevision: slot.Channel.DetailRevision,
|
|
|
|
ChannelDetail: &ChannelDetail{
|
|
|
|
DataType: slot.Channel.DataType,
|
|
|
|
Data: slot.Channel.Data,
|
|
|
|
Created: slot.Channel.Created,
|
|
|
|
Updated: slot.Channel.Updated,
|
|
|
|
Groups: channelGroups,
|
|
|
|
Cards: cards,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-28 07:01:17 +00:00
|
|
|
|