Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
1a11f0e4
Commit
1a11f0e4
authored
Jun 07, 2020
by
lain
Browse files
Chats: Change id to flake id.
parent
0365053c
Pipeline
#26899
passed with stages
in 8 minutes and 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/chat.ex
View file @
1a11f0e4
...
...
@@ -16,6 +16,8 @@ defmodule Pleroma.Chat do
It is a helper only, to make it easy to display a list of chats with other people, ordered by last bump. The actual messages are retrieved by querying the recipients of the ChatMessages.
"""
@primary_key
{
:id
,
FlakeId
.
Ecto
.
CompatType
,
autogenerate:
true
}
schema
"chats"
do
belongs_to
(
:user
,
User
,
type:
FlakeId
.
Ecto
.
CompatType
)
field
(
:recipient
,
:string
)
...
...
@@ -63,6 +65,7 @@ def bump_or_create(user_id, recipient) do
|>
changeset
(%{
user_id:
user_id
,
recipient:
recipient
})
|>
Repo
.
insert
(
on_conflict:
[
set:
[
updated_at:
NaiveDateTime
.
utc_now
()]],
returning:
true
,
conflict_target:
[
:user_id
,
:recipient
]
)
end
...
...
lib/pleroma/chat/message_reference.ex
View file @
1a11f0e4
...
...
@@ -21,7 +21,7 @@ defmodule Pleroma.Chat.MessageReference do
schema
"chat_message_references"
do
belongs_to
(
:object
,
Object
)
belongs_to
(
:chat
,
Chat
)
belongs_to
(
:chat
,
Chat
,
type:
FlakeId
.
Ecto
.
CompatType
)
field
(
:unread
,
:boolean
,
default:
true
)
...
...
priv/repo/migrations/20200607112923_change_chat_id_to_flake.exs
0 → 100644
View file @
1a11f0e4
defmodule
Pleroma
.
Repo
.
Migrations
.
ChangeChatIdToFlake
do
use
Ecto
.
Migration
def
up
do
execute
(
"""
alter table chats
drop constraint chats_pkey cascade,
alter column id drop default,
alter column id set data type uuid using cast( lpad( to_hex(id), 32, '0') as uuid),
add primary key (id)
"""
)
execute
(
"""
alter table chat_message_references
alter column chat_id set data type uuid using cast( lpad( to_hex(chat_id), 32, '0') as uuid),
add constraint chat_message_references_chat_id_fkey foreign key (chat_id) references chats(id) on delete cascade
"""
)
end
def
down
do
:ok
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment