ResolveCommentNodeID constructs a discussion comment node ID from a repository and a comment database ID. It fetches the repository's database ID via the API, then encodes the data into a "DC_" prefixed node ID.
(repo ghrepo.Interface, commentDatabaseID int64)
| 1291 | // repository and a comment database ID. It fetches the repository's database |
| 1292 | // ID via the API, then encodes the data into a "DC_" prefixed node ID. |
| 1293 | func (c *discussionClient) ResolveCommentNodeID(repo ghrepo.Interface, commentDatabaseID int64) (string, error) { |
| 1294 | meta, err := c.getRepositoryMeta(repo) |
| 1295 | if err != nil { |
| 1296 | return "", err |
| 1297 | } |
| 1298 | |
| 1299 | buf := bytes.Buffer{} |
| 1300 | parts := []int64{0, meta.DatabaseId, commentDatabaseID} |
| 1301 | |
| 1302 | encoder := msgpack.NewEncoder(&buf) |
| 1303 | encoder.UseCompactInts(true) |
| 1304 | |
| 1305 | if err := encoder.Encode(parts); err != nil { |
| 1306 | return "", fmt.Errorf("encoding comment node ID: %w", err) |
| 1307 | } |
| 1308 | |
| 1309 | encoded := base64.RawURLEncoding.EncodeToString(buf.Bytes()) |
| 1310 | return "DC_" + encoded, nil |
| 1311 | } |
nothing calls this directly
no test coverage detected