2022-01-21 00:26:59 +00:00
|
|
|
package databag
|
|
|
|
|
|
|
|
import (
|
|
|
|
"databag/internal/store"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getCardModel(card *store.Card) *Card {
|
|
|
|
|
|
|
|
// populate group id list
|
|
|
|
var groups []string;
|
|
|
|
for _, group := range card.Groups {
|
|
|
|
groups = append(groups, group.GroupId)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Card{
|
|
|
|
CardId: card.CardId,
|
2022-01-28 21:39:31 +00:00
|
|
|
NotifiedProfile: card.NotifiedProfile,
|
|
|
|
NotifiedContent: card.NotifiedContent,
|
|
|
|
NotifiedView: card.NotifiedView,
|
2022-01-21 00:26:59 +00:00
|
|
|
CardProfile: &CardProfile{
|
|
|
|
Guid: card.Guid,
|
|
|
|
Handle: card.Username,
|
|
|
|
Name: card.Name,
|
|
|
|
Description: card.Description,
|
|
|
|
Location: card.Location,
|
|
|
|
Revision: card.ProfileRevision,
|
|
|
|
ImageSet: card.Image != "",
|
|
|
|
Version: card.Version,
|
|
|
|
Node: card.Node,
|
|
|
|
},
|
|
|
|
CardData: &CardData {
|
|
|
|
Revision: card.DataRevision,
|
|
|
|
Status: card.Status,
|
|
|
|
Notes: card.Notes,
|
2022-01-21 23:08:52 +00:00
|
|
|
Token: card.OutToken,
|
2022-01-21 00:26:59 +00:00
|
|
|
Groups: groups,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 05:22:33 +00:00
|
|
|
func getGroupModel(group *store.Group) *Group {
|
|
|
|
return &Group{
|
|
|
|
GroupId: group.GroupId,
|
|
|
|
Revision: group.Revision,
|
|
|
|
DataType: group.DataType,
|
2022-02-02 18:55:45 +00:00
|
|
|
Data: group.GroupData.Data,
|
2022-01-25 05:22:33 +00:00
|
|
|
Created: group.Created,
|
|
|
|
Updated: group.Updated,
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
} else {
|
2022-01-28 07:01:17 +00:00
|
|
|
|
2022-02-01 18:03:04 +00:00
|
|
|
var groups []string;
|
2022-02-02 07:55:16 +00:00
|
|
|
if !contact {
|
2022-02-02 21:44:41 +00:00
|
|
|
for _, group := range slot.Article.Groups {
|
2022-02-02 07:55:16 +00:00
|
|
|
groups = append(groups, group.GroupId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-01 18:03:04 +00:00
|
|
|
var labels []string;
|
2022-02-02 21:44:41 +00:00
|
|
|
for _, label := range slot.Article.Labels {
|
2022-02-02 07:55:16 +00:00
|
|
|
labels = append(labels, label.LabelId)
|
2022-02-01 18:03:04 +00:00
|
|
|
}
|
2022-01-28 07:01:17 +00:00
|
|
|
|
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
|
|
|
ArticleData: &ArticleData{
|
2022-02-02 21:44:41 +00:00
|
|
|
DataType: slot.Article.DataType,
|
|
|
|
Data: slot.Article.Data,
|
|
|
|
Status: slot.Article.Status,
|
2022-02-01 18:03:04 +00:00
|
|
|
Labels: labels,
|
|
|
|
Groups: groups,
|
2022-02-02 21:44:41 +00:00
|
|
|
TagCount: slot.Article.TagCount,
|
|
|
|
Created: slot.Article.Created,
|
|
|
|
Updated: slot.Article.Updated,
|
|
|
|
TagUpdated: slot.Article.TagUpdated,
|
|
|
|
TagRevision: slot.Article.TagRevision,
|
2022-02-01 18:03:04 +00:00
|
|
|
},
|
|
|
|
}
|
2022-01-28 07:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|