Skip to content

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.

4.6 KB
Raw Blame
// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0
// source: voice_notify.sql

package store

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const getVoiceNotifyDirectPeerForAccount = `-- name: GetVoiceNotifyDirectPeerForAccount :one
SELECT peer.id,peer.tenant_id,peer.kind,peer.display_name,
       peer.account_id,peer.handle,peer.created_at,
	   (registration.status='active')::boolean AS active,
	   registration.agent_management_id
FROM rooms direct
JOIN actors caller
  ON caller.id=direct.direct_human_actor_id
 AND caller.tenant_id=direct.tenant_id
 AND caller.account_id=$1::text
 AND caller.kind='human'
JOIN active_room_members caller_membership
  ON caller_membership.room_id=direct.id AND caller_membership.actor_id=caller.id
JOIN actors peer
  ON peer.id=direct.direct_agent_actor_id AND peer.tenant_id=direct.tenant_id
JOIN active_room_members peer_membership
  ON peer_membership.room_id=direct.id AND peer_membership.actor_id=peer.id
JOIN agent_registrations registration
  ON registration.actor_id=peer.id AND registration.tenant_id=peer.tenant_id
WHERE direct.id=$2::text
  AND peer.id=$3::text
FOR KEY SHARE OF caller_membership,peer_membership,registration
`

type GetVoiceNotifyDirectPeerForAccountParams struct {
	AccountID     string `json:"account_id"`
	RoomID        string `json:"room_id"`
	TargetAgentID string `json:"target_agent_id"`
}

type GetVoiceNotifyDirectPeerForAccountRow struct {
	ID                string             `json:"id"`
	TenantID          string             `json:"tenant_id"`
	Kind              string             `json:"kind"`
	DisplayName       string             `json:"display_name"`
	AccountID         pgtype.Text        `json:"account_id"`
	Handle            pgtype.Text        `json:"handle"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	Active            bool               `json:"active"`
	AgentManagementID pgtype.Text        `json:"agent_management_id"`
}

func (q *Queries) GetVoiceNotifyDirectPeerForAccount(ctx context.Context, arg GetVoiceNotifyDirectPeerForAccountParams) (GetVoiceNotifyDirectPeerForAccountRow, error) {
	row := q.db.QueryRow(ctx, getVoiceNotifyDirectPeerForAccount, arg.AccountID, arg.RoomID, arg.TargetAgentID)
	var i GetVoiceNotifyDirectPeerForAccountRow
	err := row.Scan(
		&i.ID,
		&i.TenantID,
		&i.Kind,
		&i.DisplayName,
		&i.AccountID,
		&i.Handle,
		&i.CreatedAt,
		&i.Active,
		&i.AgentManagementID,
	)
	return i, err
}

const getVoiceNotifyDirectPeerForAccountRoom = `-- name: GetVoiceNotifyDirectPeerForAccountRoom :one
SELECT peer.id,peer.tenant_id,peer.kind,peer.display_name,
       peer.account_id,peer.handle,peer.created_at,
       (registration.status='active')::boolean AS active,
       registration.agent_management_id
FROM rooms direct
JOIN actors caller
  ON caller.id=direct.direct_human_actor_id
 AND caller.tenant_id=direct.tenant_id
 AND caller.account_id=$1::text
 AND caller.kind='human'
JOIN active_room_members caller_membership
  ON caller_membership.room_id=direct.id AND caller_membership.actor_id=caller.id
JOIN actors peer
  ON peer.id=direct.direct_agent_actor_id AND peer.tenant_id=direct.tenant_id
JOIN active_room_members peer_membership
  ON peer_membership.room_id=direct.id AND peer_membership.actor_id=peer.id
JOIN agent_registrations registration
  ON registration.actor_id=peer.id AND registration.tenant_id=peer.tenant_id
WHERE direct.id=$2::text
FOR KEY SHARE OF caller_membership,peer_membership,registration
`

type GetVoiceNotifyDirectPeerForAccountRoomParams struct {
	AccountID string `json:"account_id"`
	RoomID    string `json:"room_id"`
}

type GetVoiceNotifyDirectPeerForAccountRoomRow struct {
	ID                string             `json:"id"`
	TenantID          string             `json:"tenant_id"`
	Kind              string             `json:"kind"`
	DisplayName       string             `json:"display_name"`
	AccountID         pgtype.Text        `json:"account_id"`
	Handle            pgtype.Text        `json:"handle"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	Active            bool               `json:"active"`
	AgentManagementID pgtype.Text        `json:"agent_management_id"`
}

func (q *Queries) GetVoiceNotifyDirectPeerForAccountRoom(ctx context.Context, arg GetVoiceNotifyDirectPeerForAccountRoomParams) (GetVoiceNotifyDirectPeerForAccountRoomRow, error) {
	row := q.db.QueryRow(ctx, getVoiceNotifyDirectPeerForAccountRoom, arg.AccountID, arg.RoomID)
	var i GetVoiceNotifyDirectPeerForAccountRoomRow
	err := row.Scan(
		&i.ID,
		&i.TenantID,
		&i.Kind,
		&i.DisplayName,
		&i.AccountID,
		&i.Handle,
		&i.CreatedAt,
		&i.Active,
		&i.AgentManagementID,
	)
	return i, err
}