Skip to content

Commit

Permalink
Merge pull request #809 from alanbixby/getCurrentUserRedirect
Browse files Browse the repository at this point in the history
Fix getCurrentUser redirect error for localized languages
  • Loading branch information
Regalijan authored Jun 14, 2024
2 parents 5546771 + 5b8a3a9 commit 1e0ba5d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
43 changes: 21 additions & 22 deletions lib/games/publishToTopic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,34 @@ exports.optional = ['jar']

function publishToTopic (universeId, topic, data, jar) {
return new Promise((resolve, reject) => {

const httpOpt = {
url: `//apis.roblox.com/messaging-service/v1/universes/${universeId}/topics/${topic}`,
options: {
json: true,
resolveWithFullResponse: true,
jar,
method: 'POST',
body: { message: JSON.stringify(data) },
headers: {
'Content-Type': 'application/json'
}
options: {
json: true,
resolveWithFullResponse: true,
jar,
method: 'POST',
body: { message: JSON.stringify(data) },
headers: {
'Content-Type': 'application/json'
}
}
}

return http(httpOpt)
.then(function (res) {
if (res.statusCode === 200) {
resolve(true)
} else {
if (typeof(res.body) === "string") {
reject(new Error(`[${res.statusCode}] ${res.statusMessage} ${res.body}`))
return http(httpOpt)
.then(function (res) {
if (res.statusCode === 200) {
resolve(true)
} else {
const data = Object.assign(res.body)
reject(new Error(`[${res.statusCode}] ${data.Error} ${data.Message}`))
if (typeof (res.body) === 'string') {
reject(new Error(`[${res.statusCode}] ${res.statusMessage} ${res.body}`))
} else {
const data = Object.assign(res.body)
reject(new Error(`[${res.statusCode}] ${data.Error} ${data.Message}`))
}
}
}
})
.catch(reject)
})
.catch(reject)
})
}

Expand Down
2 changes: 1 addition & 1 deletion lib/util/getCurrentUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.func = async function (args) {
options: {
resolveWithFullResponse: true,
method: 'GET',
followRedirect: false,
followRedirect: true,
jar
}
}
Expand Down

0 comments on commit 1e0ba5d

Please sign in to comment.