Tweak field names, add more 'db:...' tags to struct field names
This commit is contained in:
parent
9dbdbdb067
commit
3f1fcf6bcd
@ -206,7 +206,7 @@ create index if not exists index_likes_tweet_id on likes (tweet_id);
|
||||
create table fake_user_sequence(latest_fake_id integer not null);
|
||||
insert into fake_user_sequence values(0x4000000000000000);
|
||||
|
||||
create table chat_room (rowid integer primary key,
|
||||
create table chat_rooms (rowid integer primary key,
|
||||
id text unique not null,
|
||||
type text not null,
|
||||
last_messaged_at integer not null,
|
||||
@ -229,14 +229,16 @@ create table chat_room_participants(rowid integer primary key,
|
||||
|
||||
create table chat_messages (rowid integer primary key,
|
||||
id integer unique not null check(typeof(id) = 'integer'),
|
||||
conversation_id text not null,
|
||||
chat_room_id text not null,
|
||||
sender_id integer not null,
|
||||
sent_at integer not null,
|
||||
request_id text not null,
|
||||
in_reply_to_id integer,
|
||||
text text not null,
|
||||
foreign key(conversation_id) references conversations(id)
|
||||
foreign key(chat_room_id) references chat_rooms(id)
|
||||
foreign key(sender_id) references users(id)
|
||||
)
|
||||
foreign key(in_reply_to_id) references chat_messages(id)
|
||||
);
|
||||
|
||||
create table chat_message_reactions (rowid integer primary key,
|
||||
id integer unique not null check(typeof(id) = 'integer'),
|
||||
|
@ -1,33 +1,31 @@
|
||||
package scraper
|
||||
|
||||
import "fmt"
|
||||
|
||||
type DMChatRoomID string
|
||||
|
||||
type DMChatParticipant struct {
|
||||
UserID UserID
|
||||
DMChatRoomID DMChatRoomID
|
||||
LastReadEventID DMMessageID
|
||||
DMChatRoomID DMChatRoomID `db:"chat_room_id"`
|
||||
UserID UserID `db:"user_id"`
|
||||
LastReadEventID DMMessageID `db:"last_read_event_id"`
|
||||
|
||||
IsChatSettingsValid bool
|
||||
IsNotificationsDisabled bool
|
||||
IsReadOnly bool
|
||||
IsTrusted bool
|
||||
IsMuted bool
|
||||
Status string
|
||||
IsChatSettingsValid bool `db:"is_chat_settings_valid"`
|
||||
IsNotificationsDisabled bool `db:"is_notifications_disabled"`
|
||||
IsMentionNotificationsDisabled bool `db:"is_mention_notifications_disabled"`
|
||||
IsReadOnly bool `db:"is_read_only"`
|
||||
IsTrusted bool `db:"is_trusted"`
|
||||
IsMuted bool `db:"is_muted"`
|
||||
Status string `db:"status"`
|
||||
}
|
||||
|
||||
type DMChatRoom struct {
|
||||
ID DMChatRoomID
|
||||
Type string
|
||||
LastMessagedAt Timestamp
|
||||
IsNSFW bool
|
||||
ID DMChatRoomID `db:"id"`
|
||||
Type string `db:"type"`
|
||||
LastMessagedAt Timestamp `db:"last_messaged_at"`
|
||||
IsNSFW bool `db:"is_nsfw"`
|
||||
|
||||
Participants []DMChatParticipant
|
||||
}
|
||||
|
||||
func ParseAPIDMChatRoom(api_room APIDMConversation) DMChatRoom {
|
||||
fmt.Printf("%#v\n", api_room)
|
||||
ret := DMChatRoom{}
|
||||
ret.ID = DMChatRoomID(api_room.ConversationID)
|
||||
ret.Type = api_room.Type
|
||||
|
@ -2,14 +2,31 @@ package scraper
|
||||
|
||||
type DMMessageID int
|
||||
|
||||
type DMReaction struct {
|
||||
ID DMMessageID `db:"id"`
|
||||
DMMessageID DMMessageID `db:"message_id"`
|
||||
SenderID UserID `db:"sender_id"`
|
||||
SentAt Timestamp `db:"sent_at"`
|
||||
Emoji string `db:"emoji"`
|
||||
}
|
||||
|
||||
func ParseAPIDMReaction(reacc APIDMReaction) DMReaction {
|
||||
ret := DMReaction{}
|
||||
ret.ID = DMMessageID(reacc.ID)
|
||||
ret.SenderID = UserID(reacc.SenderID)
|
||||
ret.SentAt = TimestampFromUnix(int64(reacc.Time))
|
||||
ret.Emoji = reacc.Emoji
|
||||
return ret
|
||||
}
|
||||
|
||||
type DMMessage struct {
|
||||
ID DMMessageID `db:"id"`
|
||||
DMChatRoomID DMChatRoomID
|
||||
SenderID UserID
|
||||
SentAt Timestamp
|
||||
RequestID string
|
||||
Text string
|
||||
InReplyToID DMMessageID
|
||||
ID DMMessageID `db:"id"`
|
||||
DMChatRoomID DMChatRoomID `db:"chat_room_id"`
|
||||
SenderID UserID `db:"sender_id"`
|
||||
SentAt Timestamp `db:"sent_at"`
|
||||
RequestID string `db:"request_id"`
|
||||
Text string `db:"text"`
|
||||
InReplyToID DMMessageID `db:"in_reply_to_id"`
|
||||
Reactions []DMReaction
|
||||
}
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
package scraper
|
||||
|
||||
type DMReaction struct {
|
||||
ID DMMessageID `db:"id"`
|
||||
DMMessageID DMMessageID
|
||||
SenderID UserID
|
||||
SentAt Timestamp
|
||||
Emoji string
|
||||
}
|
||||
|
||||
func ParseAPIDMReaction(reacc APIDMReaction) DMReaction {
|
||||
ret := DMReaction{}
|
||||
ret.ID = DMMessageID(reacc.ID)
|
||||
ret.SenderID = UserID(reacc.SenderID)
|
||||
ret.SentAt = TimestampFromUnix(int64(reacc.Time))
|
||||
ret.Emoji = reacc.Emoji
|
||||
return ret
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user