Fix string replacement
Fixes only the first occurence of `/` being replaced when parsing the current meta doc's `last` date.
This commit is contained in:
parent
e663a46242
commit
9fb8829901
@ -315,7 +315,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
|||||||
*/
|
*/
|
||||||
if (this.channelType === "room") {
|
if (this.channelType === "room") {
|
||||||
// Normal chatroom
|
// Normal chatroom
|
||||||
const channelName = this.channelName.replace(/#/,'');
|
const channelName = this.channelName.replace(/^#/,'');
|
||||||
this.channelPath = `${this.service.domain}/channels/${channelName}`;
|
this.channelPath = `${this.service.domain}/channels/${channelName}`;
|
||||||
} else {
|
} else {
|
||||||
// User direct messages
|
// User direct messages
|
||||||
@ -489,7 +489,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_buildArchiveObject () {
|
_buildArchiveObject () {
|
||||||
const roomName = this.channelName.replace(/#/,'');
|
const roomName = this.channelName.replace(/^#/,'');
|
||||||
|
|
||||||
const archive = {
|
const archive = {
|
||||||
"@id": "chat-messages/"+this.service.domain+"/channels/"+roomName+"/",
|
"@id": "chat-messages/"+this.service.domain+"/channels/"+roomName+"/",
|
||||||
@ -616,7 +616,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only update document if current date is newer than known "last"
|
// Only update document if current date is newer than known "last"
|
||||||
if (Date.parse(meta.last.replace('/','-')) > Date.parse(this.date)) {
|
if (Date.parse(meta.last.replace(/\//g,'-')) > Date.parse(this.date)) {
|
||||||
console.debug('[chat-messages]', 'Updating meta document for channel');
|
console.debug('[chat-messages]', 'Updating meta document for channel');
|
||||||
meta.last = this.dateId;
|
meta.last = this.dateId;
|
||||||
await this.client.storeObject('daily-archive-meta', this.metaPath, meta);
|
await this.client.storeObject('daily-archive-meta', this.metaPath, meta);
|
||||||
@ -630,7 +630,7 @@ const ChatMessages = function (privateClient, publicClient) {
|
|||||||
// When creating a new meta doc, we need to find the oldest archive,
|
// When creating a new meta doc, we need to find the oldest archive,
|
||||||
// because older versions of the module did not write a meta doc.
|
// because older versions of the module did not write a meta doc.
|
||||||
const first = await this._findFirstArchive();
|
const first = await this._findFirstArchive();
|
||||||
const roomName = this.channelName.replace(/#/,'');
|
const roomName = this.channelName.replace(/^#/,'');
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
'@id': `chat-messages/${this.service.domain}/channels/${roomName}/meta`,
|
'@id': `chat-messages/${this.service.domain}/channels/${roomName}/meta`,
|
||||||
@ -667,10 +667,10 @@ const ChatMessages = function (privateClient, publicClient) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _sync (obj) {
|
async _sync (archive) {
|
||||||
console.debug(`[chat-messages] Writing archive object with ${obj.today.messages.length} messages`);
|
console.debug(`[chat-messages] Writing archive object with ${archive.today.messages.length} messages`);
|
||||||
|
|
||||||
return this.client.storeObject('daily-archive', this.path, obj).then(function(){
|
return this.client.storeObject('daily-archive', this.path, archive).then(function(){
|
||||||
console.debug('[chat-messages] Archive written to remote storage');
|
console.debug('[chat-messages] Archive written to remote storage');
|
||||||
return true;
|
return true;
|
||||||
},function(error){
|
},function(error){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user