package rpc_controllers

import (
	"context"
	"gitea.pena/SQuiz/common/dal"
	"gitea.pena/SQuiz/core/internal/proto/notifyer"
)

type MailNotify struct {
	notifyer.UnimplementedQuizServiceServer
	dal *dal.DAL
}

func NewMailNotify(dal *dal.DAL) *MailNotify {
	return &MailNotify{
		dal: dal,
	}
}

func (m *MailNotify) GetQuizzes(ctx context.Context, in *notifyer.GetQuizzesRequest) (*notifyer.GetQuizzesResponse, error) {
	ids, err := m.dal.QuizRepo.GetAllQuizzesID(ctx, in.AccountId)
	if err != nil {
		return nil, err
	}
	resp := &notifyer.GetQuizzesResponse{
		QuizIds: ids,
	}
	return resp, nil
}

func (m *MailNotify) GetStartedQuizzes(ctx context.Context, in *notifyer.GetStartedQuizzesRequest) (*notifyer.GetStartedQuizzesResponse, error) {
	ids, err := m.dal.QuizRepo.GetStartedQuizzesID(ctx, in.AccountId)
	if err != nil {
		return nil, err
	}
	resp := &notifyer.GetStartedQuizzesResponse{
		QuizIds: ids,
	}
	return resp, nil
}
