2022-01-21 00:26:59 +00:00
|
|
|
package databag
|
|
|
|
|
|
|
|
import (
|
|
|
|
"databag/internal/store"
|
|
|
|
)
|
|
|
|
|
2022-02-03 06:13:46 +00:00
|
|
|
func getCardModel(slot *store.CardSlot) *Card {
|
|
|
|
|
|
|
|
if slot.Card == nil {
|
|
|
|
return &Card{
|
|
|
|
CardId: slot.CardSlotId,
|
|
|
|
}
|
|
|
|
}
|
2022-01-21 00:26:59 +00:00
|
|
|
|
|
|
|
// populate group id list
|
|
|
|
var groups []string;
|
2022-02-03 06:13:46 +00:00
|
|
|
for _, group := range slot.Card.Groups {
|
2022-02-03 07:48:17 +00:00
|
|
|
groups = append(groups, group.GroupSlot.GroupSlotId)
|
2022-01-21 00:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return &Card{
|
2022-02-03 06:13:46 +00:00
|
|
|
CardId: slot.CardSlotId,
|
|
|
|
CardData: &CardData {
|
|
|
|
NotifiedProfile: slot.Card.NotifiedProfile,
|
|
|
|
NotifiedContent: slot.Card.NotifiedContent,
|
2022-02-03 19:18:50 +00:00
|
|
|
NotifiedLabel: slot.Card.NotifiedLabel,
|
2022-02-03 06:13:46 +00:00
|
|
|
NotifiedView: slot.Card.NotifiedView,
|
|
|
|
CardProfile: &CardProfile{
|
|
|
|
Guid: slot.Card.Guid,
|
|
|
|
Handle: slot.Card.Username,
|
|
|
|
Name: slot.Card.Name,
|
|
|
|
Description: slot.Card.Description,
|
|
|
|
Location: slot.Card.Location,
|
|
|
|
Revision: slot.Card.ProfileRevision,
|
|
|
|
ImageSet: slot.Card.Image != "",
|
|
|
|
Version: slot.Card.Version,
|
|
|
|
Node: slot.Card.Node,
|
|
|
|
},
|
|
|
|
Status: slot.Card.Status,
|
|
|
|
Notes: slot.Card.Notes,
|
|
|
|
Token: slot.Card.OutToken,
|
2022-01-21 00:26:59 +00:00
|
|
|
Groups: groups,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 07:48:17 +00:00
|
|
|
func getGroupModel(slot *store.GroupSlot) *Group {
|
|
|
|
if slot.Group == nil {
|
|
|
|
return &Group{
|
|
|
|
GroupId: slot.GroupSlotId,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 05:22:33 +00:00
|
|
|
return &Group{
|
2022-02-03 07:48:17 +00:00
|
|
|
GroupId: slot.GroupSlotId,
|
|
|
|
GroupData: &GroupData {
|
|
|
|
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-02 21:44:41 +00:00
|
|
|
func getArticleModel(slot *store.ArticleSlot, contact bool, shared bool) *Article {
|
2022-01-28 07:01:17 +00:00
|
|
|
|
2022-02-02 21:44:41 +00:00
|
|
|
if !shared || slot.Article == nil {
|
2022-02-01 18:03:04 +00:00
|
|
|
return &Article{
|
2022-02-02 21:44:41 +00:00
|
|
|
ArticleId: slot.ArticleSlotId,
|
2022-02-01 18:03:04 +00:00
|
|
|
}
|
2022-02-03 06:13:46 +00:00
|
|
|
}
|
2022-01-28 07:01:17 +00:00
|
|
|
|
2022-02-03 06:13:46 +00:00
|
|
|
var groups []string;
|
|
|
|
if !contact {
|
|
|
|
for _, group := range slot.Article.Groups {
|
2022-02-03 07:48:17 +00:00
|
|
|
groups = append(groups, group.GroupSlot.GroupSlotId)
|
2022-02-02 07:55:16 +00:00
|
|
|
}
|
2022-02-03 06:13:46 +00:00
|
|
|
}
|
2022-02-02 07:55:16 +00:00
|
|
|
|
2022-02-03 06:13:46 +00:00
|
|
|
var labels []string;
|
|
|
|
for _, label := range slot.Article.Labels {
|
2022-02-03 06:52:06 +00:00
|
|
|
labels = append(labels, label.LabelSlot.LabelSlotId)
|
2022-02-03 06:13:46 +00:00
|
|
|
}
|
2022-01-28 07:01:17 +00:00
|
|
|
|
2022-02-03 06:13:46 +00:00
|
|
|
return &Article{
|
|
|
|
ArticleId: slot.ArticleSlotId,
|
|
|
|
ArticleData: &ArticleData{
|
|
|
|
DataType: slot.Article.DataType,
|
|
|
|
Data: slot.Article.Data,
|
|
|
|
Status: slot.Article.Status,
|
|
|
|
Labels: labels,
|
|
|
|
Groups: groups,
|
|
|
|
TagCount: slot.Article.TagCount,
|
|
|
|
Created: slot.Article.Created,
|
|
|
|
Updated: slot.Article.Updated,
|
|
|
|
TagUpdated: slot.Article.TagUpdated,
|
|
|
|
TagRevision: slot.Article.TagRevision,
|
|
|
|
},
|
2022-01-28 07:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|