summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2018-12-06 10:02:04 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2018-12-06 10:02:04 +0900
commit452256874930093d07ad6734f72293b4334a3b9e (patch)
tree6bf45b67be29d279201ea122b922f8dd6bde7361 /src/server/api/endpoints
parent外部サービス連携情報をPersonのfieldsに乗せて配信する (#3499) (diff)
downloadmisskey-452256874930093d07ad6734f72293b4334a3b9e.tar.gz
misskey-452256874930093d07ad6734f72293b4334a3b9e.tar.bz2
misskey-452256874930093d07ad6734f72293b4334a3b9e.zip
Emoji support in profile (#3514)
* Emoji in profile * Add emojis to fields
Diffstat (limited to 'src/server/api/endpoints')
-rw-r--r--src/server/api/endpoints/i/update.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts
index b87c3c47e7..0319550109 100644
--- a/src/server/api/endpoints/i/update.ts
+++ b/src/server/api/endpoints/i/update.ts
@@ -6,6 +6,8 @@ import acceptAllFollowRequests from '../../../../services/following/requests/acc
import { publishToFollowers } from '../../../../services/i/update';
import define from '../../define';
import getDriveFileUrl from '../../../../misc/get-drive-file-url';
+import parse from '../../../../mfm/parse';
+import { extractEmojis } from '../../../../services/note/create';
const langmap = require('langmap');
export const meta = {
@@ -191,6 +193,24 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => {
}
}
+ //#region emojis
+ if (updates.name != null || updates.description != null) {
+ let emojis = [] as string[];
+
+ if (updates.name != null) {
+ const match = updates.name.match(/:\w{1,100}:/g) as string[];
+ if (match) emojis = emojis.concat(match.map(m => m.replace(/:(\w+):/, '$1')));
+ }
+
+ if (updates.description != null) {
+ const tokens = parse(updates.description);
+ emojis = emojis.concat(extractEmojis(tokens));
+ }
+
+ updates.emojis = emojis;
+ }
+ //#endregion
+
await User.update(user._id, {
$set: updates
});