(ctx context.Context, client *gotgproto.Client, messageID int)
| 115 | } |
| 116 | |
| 117 | func FileFromMessage(ctx context.Context, client *gotgproto.Client, messageID int) (*types.File, error) { |
| 118 | key := fmt.Sprintf("file:%d:%d", messageID, client.Self.ID) |
| 119 | log := Logger.Named("GetMessageMedia") |
| 120 | var cachedMedia types.File |
| 121 | err := cache.GetCache().Get(key, &cachedMedia) |
| 122 | if err == nil { |
| 123 | log.Debug("Using cached media message properties", zap.Int("messageID", messageID), zap.Int64("clientID", client.Self.ID)) |
| 124 | return &cachedMedia, nil |
| 125 | } |
| 126 | log.Debug("Fetching file properties from message ID", zap.Int("messageID", messageID), zap.Int64("clientID", client.Self.ID)) |
| 127 | message, err := GetTGMessage(ctx, client, messageID) |
| 128 | if err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | file, err := FileFromMedia(message.Media) |
| 132 | if err != nil { |
| 133 | return nil, err |
| 134 | } |
| 135 | err = cache.GetCache().Set( |
| 136 | key, |
| 137 | file, |
| 138 | 3600, |
| 139 | ) |
| 140 | if err != nil { |
| 141 | return nil, err |
| 142 | } |
| 143 | return file, nil |
| 144 | } |
| 145 | |
| 146 | func GetLogChannelPeer(ctx context.Context, api *tg.Client, peerStorage *storage.PeerStorage) (*tg.InputChannel, error) { |
| 147 | cachedInputPeer := peerStorage.GetInputPeerById(config.ValueOf.LogChannelID) |
no test coverage detected