From a7440380c83d6e93671a802670c1481c4675740f Mon Sep 17 00:00:00 2001 From: mattuy Date: Mon, 17 Dec 2018 11:31:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9GetUserPhoto=20API=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 +- design/stormchat.mdj | 54 ++++++++++++++++++----- stormchat-server/src/stormchat/session.go | 9 +++- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/.gitattributes b/.gitattributes index d6da092..245101f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,5 @@ ##set starUML design file to binary -*.mdj binary +*.mdj binary ############################################################################### # Set default behavior to automatically normalize line endings. diff --git a/design/stormchat.mdj b/design/stormchat.mdj index 0840885..da46cfd 100644 --- a/design/stormchat.mdj +++ b/design/stormchat.mdj @@ -9101,10 +9101,10 @@ }, "font": "Arial;13;0", "left": 1268, - "top": 481, + "top": 505, "width": 393, "height": 25, - "text": "Error,错误文本,成功为空;" + "text": "Error,保留,总是为空;" }, { "_type": "UMLNoteView", @@ -9144,6 +9144,32 @@ "width": 393, "height": 25, "text": "NeedResullt,当此字段不为0时要求服务器返回处理结果" + }, + { + "_type": "UMLNoteView", + "_id": "AAAAAAFnui/PRD4Nkb0=", + "_parent": { + "$ref": "AAAAAAFnCJD5xebaqTo=" + }, + "font": "Arial;13;0", + "left": 1268, + "top": 376, + "width": 393, + "height": 25, + "text": "User,要获取头像的用户名" + }, + { + "_type": "UMLNoteView", + "_id": "AAAAAAFnujFC6j4ew94=", + "_parent": { + "$ref": "AAAAAAFnCJD5xebaqTo=" + }, + "font": "Arial;13;0", + "left": 1268, + "top": 480, + "width": 393, + "height": 25, + "text": "Length,头像数据长度,为0则头像数据无效;" } ] }, @@ -10236,7 +10262,8 @@ "_parent": { "$ref": "AAAAAAFnp7WMX/VycEU=" }, - "name": "event OnPanic" + "name": "event OnPanic", + "type": "" }, { "_type": "UMLAttribute", @@ -10244,7 +10271,8 @@ "_parent": { "$ref": "AAAAAAFnp7WMX/VycEU=" }, - "name": "event OnOffline" + "name": "event OnOffline", + "type": "" }, { "_type": "UMLAttribute", @@ -10252,7 +10280,8 @@ "_parent": { "$ref": "AAAAAAFnp7WMX/VycEU=" }, - "name": "event OnMessage" + "name": "event OnMessage", + "type": "" }, { "_type": "UMLAttribute", @@ -10260,7 +10289,8 @@ "_parent": { "$ref": "AAAAAAFnp7WMX/VycEU=" }, - "name": "event OnSendMessageDone" + "name": "event OnSendMessageDone", + "type": "" }, { "_type": "UMLAttribute", @@ -10268,7 +10298,8 @@ "_parent": { "$ref": "AAAAAAFnp7WMX/VycEU=" }, - "name": "event OnUpdateUserInfoDone" + "name": "event OnUpdateUserInfoDone", + "type": "" }, { "_type": "UMLAttribute", @@ -10285,7 +10316,8 @@ "_parent": { "$ref": "AAAAAAFnp7WMX/VycEU=" }, - "name": "event OnGetUserListDone" + "name": "event OnGetUserListDone", + "type": "" }, { "_type": "UMLAttribute", @@ -10293,7 +10325,8 @@ "_parent": { "$ref": "AAAAAAFnp7WMX/VycEU=" }, - "name": "event OnGetUserPhotoDoneHandler" + "name": "event OnGetUserPhotoDoneHandler", + "type": "" }, { "_type": "UMLAttribute", @@ -10386,7 +10419,8 @@ "_parent": { "$ref": "AAAAAAFnp8DShvXnMlE=" }, - "name": "callback" + "name": "callback", + "type": "" } ] }, diff --git a/stormchat-server/src/stormchat/session.go b/stormchat-server/src/stormchat/session.go index 6bfc57a..b8c1621 100644 --- a/stormchat-server/src/stormchat/session.go +++ b/stormchat-server/src/stormchat/session.go @@ -256,8 +256,15 @@ func (session *Session) GetUserPhotoHandler(headInfo map[string]string) { head := make(map[string]string) head[keyname_token] = headInfo[keyname_token] head[keyname_operation] = headInfo[keyname_operation] + head["Length"] = "0" head["Error"] = "" - photo := GetUserPhoto(session.sender.User) + var photo []byte + if username, ok := headInfo["User"]; ok { + photo = GetUserPhoto(username) + } else { + photo = GetUserPhoto(session.sender.User) + } + head["Length"] = string(len(photo)) session.SendData(head, photo) }