Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: message_reactions.sql
package store
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const countMessageReactions = `-- name: CountMessageReactions :one
SELECT count(*)::bigint FROM message_reactions WHERE message_id=$1
`
func (q *Queries) CountMessageReactions(ctx context.Context, messageID string) (int64, error) {
row := q.db.QueryRow(ctx, countMessageReactions, messageID)
var column_1 int64
err := row.Scan(&column_1)
return column_1, err
}
const deleteMessageReaction = `-- name: DeleteMessageReaction :execrows
DELETE FROM message_reactions
WHERE message_id=$1 AND actor_id=$2 AND reaction_id=$3
`
type DeleteMessageReactionParams struct {
MessageID string `json:"message_id"`
ActorID string `json:"actor_id"`
ReactionID string `json:"reaction_id"`
}
func (q *Queries) DeleteMessageReaction(ctx context.Context, arg DeleteMessageReactionParams) (int64, error) {
result, err := q.db.Exec(ctx, deleteMessageReaction, arg.MessageID, arg.ActorID, arg.ReactionID)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const getAgentMessageReactionAuthority = `-- name: GetAgentMessageReactionAuthority :one
SELECT message.id AS message_id,message.tenant_id,message.room_id,
collaboration_membership_room_id(message.room_id) AS membership_room_id,
(message.message_kind='conversation'
AND message.card_context_message_id IS NULL
AND NOT EXISTS(SELECT 1 FROM message_cards card WHERE card.message_id=message.id)
)::boolean AS supported
FROM messages message
JOIN room_members membership
ON membership.tenant_id=message.tenant_id
AND membership.room_id=collaboration_membership_room_id(message.room_id)
AND membership.actor_id=$1::text
JOIN rooms room
ON room.id=membership.room_id AND room.tenant_id=membership.tenant_id AND room.deletion_started_at IS NULL
WHERE message.id=$2::text
AND message.tenant_id=$3::text
FOR KEY SHARE OF message,membership
`
type GetAgentMessageReactionAuthorityParams struct {
AgentActorID string `json:"agent_actor_id"`
MessageID string `json:"message_id"`
TenantID string `json:"tenant_id"`
}
type GetAgentMessageReactionAuthorityRow struct {
MessageID string `json:"message_id"`
TenantID string `json:"tenant_id"`
RoomID string `json:"room_id"`
MembershipRoomID string `json:"membership_room_id"`
Supported bool `json:"supported"`
}
func (q *Queries) GetAgentMessageReactionAuthority(ctx context.Context, arg GetAgentMessageReactionAuthorityParams) (GetAgentMessageReactionAuthorityRow, error) {
row := q.db.QueryRow(ctx, getAgentMessageReactionAuthority, arg.AgentActorID, arg.MessageID, arg.TenantID)
var i GetAgentMessageReactionAuthorityRow
err := row.Scan(
&i.MessageID,
&i.TenantID,
&i.RoomID,
&i.MembershipRoomID,
&i.Supported,
)
return i, err
}
const getHumanMessageReactionAuthority = `-- name: GetHumanMessageReactionAuthority :one
SELECT message.id AS message_id,message.tenant_id,message.room_id,caller.id AS actor_id,
(message.message_kind='conversation'
AND message.card_context_message_id IS NULL
AND NOT EXISTS(SELECT 1 FROM message_cards card WHERE card.message_id=message.id)
)::boolean AS supported
FROM messages message
JOIN actors caller
ON caller.tenant_id=message.tenant_id
AND caller.account_id=$1::text
AND caller.kind='human'
JOIN room_members membership
ON membership.tenant_id=message.tenant_id
AND membership.room_id=collaboration_membership_room_id(message.room_id)
AND membership.actor_id=caller.id
WHERE message.id=$2::text
AND message.room_id=$3::text
FOR KEY SHARE OF message,membership
`
type GetHumanMessageReactionAuthorityParams struct {
AccountID string `json:"account_id"`
MessageID string `json:"message_id"`
RoomID string `json:"room_id"`
}
type GetHumanMessageReactionAuthorityRow struct {
MessageID string `json:"message_id"`
TenantID string `json:"tenant_id"`
RoomID string `json:"room_id"`
ActorID string `json:"actor_id"`
Supported bool `json:"supported"`
}
func (q *Queries) GetHumanMessageReactionAuthority(ctx context.Context, arg GetHumanMessageReactionAuthorityParams) (GetHumanMessageReactionAuthorityRow, error) {
row := q.db.QueryRow(ctx, getHumanMessageReactionAuthority, arg.AccountID, arg.MessageID, arg.RoomID)
var i GetHumanMessageReactionAuthorityRow
err := row.Scan(
&i.MessageID,
&i.TenantID,
&i.RoomID,
&i.ActorID,
&i.Supported,
)
return i, err
}
const listMessageReactionsForMessages = `-- name: ListMessageReactionsForMessages :many
SELECT message_id,reaction_id,actor_id,created_at
FROM message_reactions
WHERE message_id=ANY($1::text[])
ORDER BY message_id,created_at,reaction_id,actor_id
`
type ListMessageReactionsForMessagesRow struct {
MessageID string `json:"message_id"`
ReactionID string `json:"reaction_id"`
ActorID string `json:"actor_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
func (q *Queries) ListMessageReactionsForMessages(ctx context.Context, messageIds []string) ([]ListMessageReactionsForMessagesRow, error) {
rows, err := q.db.Query(ctx, listMessageReactionsForMessages, messageIds)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListMessageReactionsForMessagesRow{}
for rows.Next() {
var i ListMessageReactionsForMessagesRow
if err := rows.Scan(
&i.MessageID,
&i.ReactionID,
&i.ActorID,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const messageReactionExists = `-- name: MessageReactionExists :one
SELECT EXISTS(
SELECT 1 FROM message_reactions
WHERE message_id=$1 AND actor_id=$2 AND reaction_id=$3
)::boolean
`
type MessageReactionExistsParams struct {
MessageID string `json:"message_id"`
ActorID string `json:"actor_id"`
ReactionID string `json:"reaction_id"`
}
func (q *Queries) MessageReactionExists(ctx context.Context, arg MessageReactionExistsParams) (bool, error) {
row := q.db.QueryRow(ctx, messageReactionExists, arg.MessageID, arg.ActorID, arg.ReactionID)
var column_1 bool
err := row.Scan(&column_1)
return column_1, err
}
const putMessageReaction = `-- name: PutMessageReaction :execrows
INSERT INTO message_reactions(message_id,tenant_id,room_id,actor_id,reaction_id)
VALUES($1,$2,$3,$4,$5)
ON CONFLICT DO NOTHING
`
type PutMessageReactionParams struct {
MessageID string `json:"message_id"`
TenantID string `json:"tenant_id"`
RoomID string `json:"room_id"`
ActorID string `json:"actor_id"`
ReactionID string `json:"reaction_id"`
}
func (q *Queries) PutMessageReaction(ctx context.Context, arg PutMessageReactionParams) (int64, error) {
result, err := q.db.Exec(ctx, putMessageReaction,
arg.MessageID,
arg.TenantID,
arg.RoomID,
arg.ActorID,
arg.ReactionID,
)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}