-
Notifications
You must be signed in to change notification settings - Fork 0
/
repository.go
29 lines (22 loc) · 1.04 KB
/
repository.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package repository
import (
"context"
"time"
"firebase.google.com/go/v4/auth"
"github.com/kokoichi206/awesome-chat-app/backend/model"
"github.com/kokoichi206/awesome-chat-app/backend/model/response"
)
// interface for database operations.
type Database interface {
SelectUser(ctx context.Context, email string) (*model.User, error)
UpsertUser(ctx context.Context, name, email, pictureUrl string, updatedAt time.Time) error
SelectRoomUsers(ctx context.Context, roomID string) ([]*response.RoomUser, error)
SelectMessages(ctx context.Context, roomID string, lastReadAt time.Time) ([]*model.Message, error)
InsertMessage(ctx context.Context, roomID, userID, content string, messageType model.MessageType, postedAt time.Time) error
IsUserInRoom(ctx context.Context, userID, roomID string) (bool, error)
}
type Firebase interface {
VerifyIDToken(ctx context.Context, idToken string) (*auth.Token, error)
CreateSession(ctx context.Context, idToken string) (string, error)
VerifySessionCookie(ctx context.Context, cookie string) (*auth.Token, error)
}