diff --git a/core/message_area.js b/core/message_area.js index e5227ef0..98647cfd 100644 --- a/core/message_area.js +++ b/core/message_area.js @@ -353,13 +353,19 @@ function getNewMessagesInAreaForUser(userId, areaTag, cb) { }); } -function getMessageListForArea(client, areaTag, cb) { - const filter = { - areaTag, - resultType : 'messageList', - sort : 'messageId', - order : 'ascending', - }; +function getMessageListForArea(client, areaTag, filter, cb) +{ + if(!cb && _.isFunction(filter)) { + cb = filter; + filter = { + areaTag, + resultType : 'messageList', + sort : 'messageId', + order : 'ascending' + }; + } else { + Object.assign(filter, { areaTag } ); + } if(Message.isPrivateAreaTag(areaTag)) { filter.privateTagUserId = client.user.userId; diff --git a/core/servers/content/gopher.js b/core/servers/content/gopher.js index 37cd9adb..da09acd9 100644 --- a/core/servers/content/gopher.js +++ b/core/servers/content/gopher.js @@ -249,7 +249,7 @@ exports.getModule = class GopherModule extends ServerModule { return message.load( { uuid : msgUuid }, err => { if(err) { - this.log.debug( { uuid : msgUuid }, 'Attempted access to non-existant message UUID!'); + this.log.debug( { uuid : msgUuid }, 'Attempted access to non-existent message UUID!'); return this.notFoundGenerator(selectorMatch, cb); } @@ -292,10 +292,17 @@ ${msgBody} return this.notFoundGenerator(selectorMatch, cb); } - return getMessageListForArea(null, areaTag, (err, msgList) => { + const filter = { + resultType : 'messageList', + sort : 'messageId', + order : 'descending', // we want newest messages first for Gopher + }; + + return getMessageListForArea(null, areaTag, filter, (err, msgList) => { const response = [ this.makeItem(ItemTypes.InfoMessage, '-'.repeat(70)), this.makeItem(ItemTypes.InfoMessage, `Messages in ${area.name}`), + this.makeItem(ItemTypes.InfoMessage, '(newest first)'), this.makeItem(ItemTypes.InfoMessage, '-'.repeat(70)), ...msgList.map(msg => this.makeItem( ItemTypes.TextFile,