summaryrefslogtreecommitdiff
path: root/addChat.go
blob: 972bb426d84d8ca2c46a5eb21363a6288347bb42 (plain)
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
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0

package chatpb

import (
	"time"

	"go.wit.com/log"
	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)

// returns true if the pb was added
// to indicate that ConfigSave() should be run to write it out to disk
func (c *Chat) AddGeminiRequest(fname string, age time.Time, pb *GeminiRequest) bool {
	for _, e := range c.GetEntries() {
		if e.GetContentFile() == fname {
			log.Info("fname already here", fname)
			return false
		}
	}
	e := new(ChatEntry)
	e.Ctime = timestamppb.New(age)
	e.From = Who_USER
	e.ContentFile = fname
	e.GeminiRequest = pb
	c.AppendEntry(e)
	return true
}