Compare commits
1 Commits
main
...
discuz-imp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cae1e7c266 |
3
Gemfile
3
Gemfile
@ -250,12 +250,13 @@ gem "sanitize"
|
||||
if ENV["IMPORT"] == "1"
|
||||
gem "mysql2"
|
||||
gem "redcarpet"
|
||||
gem "php_serialize"
|
||||
gem "miro"
|
||||
|
||||
# NOTE: in import mode the version of sqlite can matter a lot, so we stick it to a specific one
|
||||
gem "sqlite3", "~> 1.3", ">= 1.3.13"
|
||||
gem "ruby-bbcode-to-md", git: "https://github.com/nlalonde/ruby-bbcode-to-md"
|
||||
gem "reverse_markdown"
|
||||
gem "tiny_tds"
|
||||
gem "csv"
|
||||
|
||||
gem "parallel", require: false
|
||||
|
||||
@ -613,7 +613,6 @@ export default class ChatLivePane extends Component {
|
||||
const message = ChatMessage.create(this.args.channel, data.chat_message);
|
||||
this.args.channel.addMessages([message]);
|
||||
this.scrollToLatestMessage();
|
||||
this.updateLastReadMessage();
|
||||
} else {
|
||||
// If we are almost at the bottom, we append the message and notice the user
|
||||
const message = ChatMessage.create(this.args.channel, data.chat_message);
|
||||
@ -896,19 +895,16 @@ export default class ChatLivePane extends Component {
|
||||
@action
|
||||
editLastMessageRequested() {
|
||||
const lastUserMessage = this.args.channel.messages.findLast(
|
||||
(message) => message.user.id === this.currentUser.id
|
||||
(message) =>
|
||||
message.user.id === this.currentUser.id &&
|
||||
!message.staged &&
|
||||
!message.error
|
||||
);
|
||||
|
||||
if (!lastUserMessage) {
|
||||
return;
|
||||
if (lastUserMessage) {
|
||||
this.editingMessage = lastUserMessage;
|
||||
this._focusComposer();
|
||||
}
|
||||
|
||||
if (lastUserMessage.staged || lastUserMessage.error) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.editingMessage = lastUserMessage;
|
||||
this._focusComposer();
|
||||
}
|
||||
|
||||
@action
|
||||
|
||||
@ -384,7 +384,6 @@ $float-height: 530px;
|
||||
|
||||
.d-icon {
|
||||
color: var(--secondary);
|
||||
margin-left: 1px; // "fixes" the 1px svg shift
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -56,9 +56,7 @@
|
||||
}
|
||||
|
||||
.chat-message-separator__text-container {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
height: 40px;
|
||||
padding-top: 7px;
|
||||
position: sticky;
|
||||
top: -1px;
|
||||
|
||||
@ -100,7 +98,11 @@
|
||||
|
||||
.chat-message-separator__line {
|
||||
border-top: 1px solid var(--secondary-high);
|
||||
left: 0;
|
||||
margin: 0 0 -1px;
|
||||
position: relative;
|
||||
right: 0;
|
||||
top: -1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,19 +70,5 @@ RSpec.describe "Shortcuts | chat composer", type: :system, js: true do
|
||||
|
||||
expect(page.find(".chat-composer-message-details")).to have_content(message_1.message)
|
||||
end
|
||||
|
||||
context "when last message is not editable" do
|
||||
after { page.driver.browser.network_conditions = { offline: false } }
|
||||
|
||||
it "does not edit a message" do
|
||||
chat.visit_channel(channel_1)
|
||||
page.driver.browser.network_conditions = { offline: true }
|
||||
channel_page.send_message("Hello world")
|
||||
|
||||
find(".chat-composer-input").send_keys(:arrow_up)
|
||||
|
||||
expect(page).to have_no_css(".chat-composer-message-details")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -15,7 +15,7 @@ require "mysql2"
|
||||
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
|
||||
|
||||
class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
DISCUZX_DB = "ultrax"
|
||||
DISCUZX_DB = "db_name"
|
||||
DB_TABLE_PREFIX = "pre_"
|
||||
BATCH_SIZE = 1000
|
||||
ORIGINAL_SITE_PREFIX = "oldsite.example.com/forums" # without http(s)://
|
||||
@ -26,6 +26,8 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
AVATAR_DIR = "/uc_server/data/avatar"
|
||||
ATTACHMENT_DIR = "/data/attachment/forum"
|
||||
AUTHORIZED_EXTENSIONS = %w[jpg jpeg png gif zip rar pdf]
|
||||
IMPORT_UPLOADS = false
|
||||
IMPORT_PASSWORDS = false
|
||||
|
||||
def initialize
|
||||
super
|
||||
@ -35,6 +37,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
host: "localhost",
|
||||
username: "root",
|
||||
#password: "password",
|
||||
port: "3306",
|
||||
database: DISCUZX_DB,
|
||||
)
|
||||
@first_post_id_by_topic_id = {}
|
||||
@ -58,7 +61,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
import_categories
|
||||
import_posts
|
||||
import_private_messages
|
||||
import_attachments
|
||||
import_attachments if IMPORT_UPLOADS
|
||||
end
|
||||
|
||||
# add the prefix to the table name
|
||||
@ -115,8 +118,8 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
@duplicated_email = {}
|
||||
results =
|
||||
mysql_query(
|
||||
"select a.uid uid, b.uid import_id from pre_common_member a
|
||||
join (select uid, email from pre_common_member group by email having count(email) > 1 order by uid asc) b USING(email)
|
||||
"select a.uid uid, b.uid import_id from #{table_name "common_member"} a
|
||||
join (select uid, email from #{table_name "common_member"} group by email having count(email) > 1 order by uid asc) b USING(email)
|
||||
where a.uid != b.uid",
|
||||
)
|
||||
|
||||
@ -176,7 +179,6 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
email: user["email"],
|
||||
username: user["username"],
|
||||
name: first_exists(user["realname"], user["customstatus"], user["username"]),
|
||||
import_pass: user["password_hash"],
|
||||
active: true,
|
||||
salt: user["salt"],
|
||||
# TODO: title: user['customstatus'], # move custom title to name since discourse can't let user custom title https://meta.discourse.org/t/let-users-custom-their-title/37626
|
||||
@ -231,7 +233,8 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
),
|
||||
post_create_action:
|
||||
lambda do |newmember|
|
||||
if user["avatar_exists"] == (1) && newmember.uploaded_avatar_id.blank?
|
||||
if user["avatar_exists"] == (1) && newmember.uploaded_avatar_id.blank? &&
|
||||
IMPORT_UPLOADS
|
||||
path, filename = discuzx_avatar_fullpath(user["id"])
|
||||
if path
|
||||
begin
|
||||
@ -306,10 +309,6 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
end
|
||||
end
|
||||
|
||||
# we don't send email to the unconfirmed user
|
||||
if newmember.email_digests
|
||||
newmember.update(email_digests: user["email_confirmed"] == 1)
|
||||
end
|
||||
if !newmember.name.blank? && newmember.name == (newmember.username)
|
||||
newmember.update(name: "")
|
||||
end
|
||||
@ -471,7 +470,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
WHERE tid = #{m["topic_id"]}
|
||||
ORDER BY displayorder",
|
||||
)
|
||||
if results.empty?
|
||||
if results.count == 0
|
||||
puts "WARNING: can't find poll options for topic #{m["topic_id"]}, skip poll"
|
||||
else
|
||||
mapped[
|
||||
|
||||
Reference in New Issue
Block a user