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);
|
create table fake_user_sequence(latest_fake_id integer not null);
|
||||||
insert into fake_user_sequence values(0x4000000000000000);
|
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,
|
id text unique not null,
|
||||||
type text not null,
|
type text not null,
|
||||||
last_messaged_at integer 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,
|
create table chat_messages (rowid integer primary key,
|
||||||
id integer unique not null check(typeof(id) = 'integer'),
|
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,
|
sender_id integer not null,
|
||||||
sent_at integer not null,
|
sent_at integer not null,
|
||||||
request_id text not null,
|
request_id text not null,
|
||||||
|
in_reply_to_id integer,
|
||||||
text text not null,
|
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(sender_id) references users(id)
|
||||||
)
|
foreign key(in_reply_to_id) references chat_messages(id)
|
||||||
|
);
|
||||||
|
|
||||||
create table chat_message_reactions (rowid integer primary key,
|
create table chat_message_reactions (rowid integer primary key,
|
||||||
id integer unique not null check(typeof(id) = 'integer'),
|
id integer unique not null check(typeof(id) = 'integer'),
|
||||||
|
@ -1,33 +1,31 @@
|
|||||||
package scraper
|
package scraper
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
type DMChatRoomID string
|
type DMChatRoomID string
|
||||||
|
|
||||||
type DMChatParticipant struct {
|
type DMChatParticipant struct {
|
||||||
UserID UserID
|
DMChatRoomID DMChatRoomID `db:"chat_room_id"`
|
||||||
DMChatRoomID DMChatRoomID
|
UserID UserID `db:"user_id"`
|
||||||
LastReadEventID DMMessageID
|
LastReadEventID DMMessageID `db:"last_read_event_id"`
|
||||||
|
|
||||||
IsChatSettingsValid bool
|
IsChatSettingsValid bool `db:"is_chat_settings_valid"`
|
||||||
IsNotificationsDisabled bool
|
IsNotificationsDisabled bool `db:"is_notifications_disabled"`
|
||||||
IsReadOnly bool
|
IsMentionNotificationsDisabled bool `db:"is_mention_notifications_disabled"`
|
||||||
IsTrusted bool
|
IsReadOnly bool `db:"is_read_only"`
|
||||||
IsMuted bool
|
IsTrusted bool `db:"is_trusted"`
|
||||||
Status string
|
IsMuted bool `db:"is_muted"`
|
||||||
|
Status string `db:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DMChatRoom struct {
|
type DMChatRoom struct {
|
||||||
ID DMChatRoomID
|
ID DMChatRoomID `db:"id"`
|
||||||
Type string
|
Type string `db:"type"`
|
||||||
LastMessagedAt Timestamp
|
LastMessagedAt Timestamp `db:"last_messaged_at"`
|
||||||
IsNSFW bool
|
IsNSFW bool `db:"is_nsfw"`
|
||||||
|
|
||||||
Participants []DMChatParticipant
|
Participants []DMChatParticipant
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseAPIDMChatRoom(api_room APIDMConversation) DMChatRoom {
|
func ParseAPIDMChatRoom(api_room APIDMConversation) DMChatRoom {
|
||||||
fmt.Printf("%#v\n", api_room)
|
|
||||||
ret := DMChatRoom{}
|
ret := DMChatRoom{}
|
||||||
ret.ID = DMChatRoomID(api_room.ConversationID)
|
ret.ID = DMChatRoomID(api_room.ConversationID)
|
||||||
ret.Type = api_room.Type
|
ret.Type = api_room.Type
|
||||||
|
@ -2,14 +2,31 @@ package scraper
|
|||||||
|
|
||||||
type DMMessageID int
|
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 {
|
type DMMessage struct {
|
||||||
ID DMMessageID `db:"id"`
|
ID DMMessageID `db:"id"`
|
||||||
DMChatRoomID DMChatRoomID
|
DMChatRoomID DMChatRoomID `db:"chat_room_id"`
|
||||||
SenderID UserID
|
SenderID UserID `db:"sender_id"`
|
||||||
SentAt Timestamp
|
SentAt Timestamp `db:"sent_at"`
|
||||||
RequestID string
|
RequestID string `db:"request_id"`
|
||||||
Text string
|
Text string `db:"text"`
|
||||||
InReplyToID DMMessageID
|
InReplyToID DMMessageID `db:"in_reply_to_id"`
|
||||||
Reactions []DMReaction
|
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