-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp_messages.go
More file actions
66 lines (56 loc) · 2.04 KB
/
app_messages.go
File metadata and controls
66 lines (56 loc) · 2.04 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
// SendText отправляет текстовое сообщение.
func (a *App) SendText(contactID, text, replyToID string) error {
return a.core.SendText(contactID, text, replyToID)
}
// SendFileMessage отправляет файлы.
func (a *App) SendFileMessage(chatID, text, replyToID string, files []string, isRaw bool) error {
return a.core.SendFileMessage(chatID, text, replyToID, files, isRaw)
}
// GetMessages возвращает историю сообщений.
func (a *App) GetMessages(contactID string, limit, offset int) ([]*MessageInfo, error) {
coreMsgs, err := a.core.GetMessages(contactID, limit, offset)
if err != nil {
return nil, err
}
result := make([]*MessageInfo, len(coreMsgs))
for i, m := range coreMsgs {
info := &MessageInfo{
ID: m.ID,
Content: m.Content,
Timestamp: m.Timestamp,
IsOutgoing: m.IsOutgoing,
Status: m.Status,
ContentType: m.ContentType,
Attachments: m.Attachments,
ReplyToID: m.ReplyToID,
ReplyPreview: m.ReplyPreview,
}
result[i] = info
}
return result, nil
}
// EditMessage редактирует сообщение.
func (a *App) EditMessage(messageID, newContent string) error {
return a.core.EditMessage(messageID, newContent)
}
// DeleteMessage удаляет сообщение.
func (a *App) DeleteMessage(messageID string) error {
return a.core.DeleteMessage(messageID)
}
// MarkChatAsRead помечает чат прочитанным.
func (a *App) MarkChatAsRead(chatID string) error {
return a.core.MarkChatAsRead(chatID)
}
// GetUnreadCount возвращает общее количество непрочитанных.
func (a *App) GetUnreadCount() (int, error) {
return a.core.GetUnreadCount()
}
// AcceptFileTransfer принимает файлы.
func (a *App) AcceptFileTransfer(messageID string) error {
return a.core.AcceptFileTransfer(messageID)
}
// DeclineFileTransfer отклоняет файлы.
func (a *App) DeclineFileTransfer(messageID string) error {
return a.core.DeclineFileTransfer(messageID)
}