Change instance emojis code to retrieve all (even if servers didn't send them as Emoji object)
This commit is contained in:
parent
2ad27897fe
commit
a3dfbbdde4
|
@ -6,10 +6,15 @@ module.exports = {
|
||||||
get: [auth.enforceSession, async (req, res) => {
|
get: [auth.enforceSession, async (req, res) => {
|
||||||
var result = {}
|
var result = {}
|
||||||
|
|
||||||
const masto_emojis = await db.table.objects().find(
|
const persons = await db.table.objects().find({
|
||||||
{ type: 'http://joinmastodon.org/ns#Emoji' }).toArray()
|
type: "Person",
|
||||||
for (var i = 0; i < masto_emojis.length; i++) {
|
tag: { $elemMatch: { type: "http://joinmastodon.org/ns#Emoji" }},
|
||||||
const emoji = masto_emojis[i]
|
}).project({ tag: 1 }).toArray()
|
||||||
|
for (var i = 0; i < persons.length; i++) {
|
||||||
|
for (var j = 0; j < persons[i].tag.length; j++) {
|
||||||
|
const emoji = persons[i].tag[j]
|
||||||
|
if (emoji.type !== 'http://joinmastodon.org/ns#Emoji')
|
||||||
|
continue
|
||||||
var name = utils.firstIfArray(emoji.name)
|
var name = utils.firstIfArray(emoji.name)
|
||||||
if (name === null) continue
|
if (name === null) continue
|
||||||
name = name.replace(/^:/,'').replace(/:$/,'').trim()
|
name = name.replace(/^:/,'').replace(/:$/,'').trim()
|
||||||
|
@ -27,6 +32,7 @@ module.exports = {
|
||||||
url,
|
url,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: support local emojis later
|
// TODO: support local emojis later
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue