MCPcopy Create free account
hub / github.com/chanify/chanify / TimelineContent

Method TimelineContent

model/message.go:55–90  ·  view source on GitHub ↗

TimelineContent set timeline notification

(code string, title string, ts *time.Time, items []*MsgTimeItem)

Source from the content-addressed store, hash-verified

53
54// TimelineContent set timeline notification
55func (m *Message) TimelineContent(code string, title string, ts *time.Time, items []*MsgTimeItem) *Message {
56 tis := []*pb.TimeItem{}
57 for _, item := range items {
58 ti := &pb.TimeItem{Name: item.Name}
59 switch v := item.Value.(type) {
60 case int:
61 ti.ValueType = pb.ValueType_ValueTypeInteger
62 ti.IntegerValue = int64(v)
63 case int64:
64 ti.ValueType = pb.ValueType_ValueTypeInteger
65 ti.IntegerValue = v
66 case float64:
67 ti.ValueType = pb.ValueType_ValueTypeDouble
68 ti.DoubleValue = v
69 default:
70 continue
71 }
72 tis = append(tis, ti)
73 }
74 if ts == nil {
75 var t = time.Now()
76 ts = &t
77 }
78 ctx := &pb.MsgContent{
79 Type: pb.MsgType_Timeline,
80 Title: title,
81 TimeContent: &pb.TimeContent{
82 Code: code,
83 Timestamp: uint64(ts.UTC().UnixNano() / 1e6),
84 TimeItems: tis,
85 },
86 }
87 m.Content, _ = proto.Marshal(ctx)
88 m.isTimeline = true
89 return m
90}
91
92// TextContent set text notification
93func (m *Message) TextContent(text string, title string, copytext string, autocopy string) *Message {

Callers 3

TestTimeContentFunction · 0.95
TestMessageChannelFunction · 0.95
handlePostSenderMethod · 0.80

Calls 1

MarshalMethod · 0.80

Tested by 2

TestTimeContentFunction · 0.76
TestMessageChannelFunction · 0.76