Skip to content

Commit c4fed44

Browse files
authored
Merge pull request #1 from duckchat/beta
1.0-beta-5
2 parents 2b268de + e4002e8 commit c4fed44

45 files changed

Lines changed: 877 additions & 799 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>
66
> `也支持单机部署,非常灵活` - `iOS、Android、Web全端支持`
77
8-
## 当前版本(1.0-beta-4)
8+
## 当前版本(1.0-beta-5)
99

1010
> **向我们提问、反馈问题**
1111
>

src/controller/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.DS_Store

src/controller/Api/Friend/Api_Friend_ApplyController.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function checkIsFriend($toUserId)
8686
$errorCode = $this->zalyError->errorFriendApplyFriendExists;
8787
$errorInfo = $this->zalyError->getErrorInfo($errorCode);
8888
$this->setRpcError($errorCode, $errorInfo);
89-
throw new Exception("no user id");
89+
throw new Exception($errorInfo);
9090
}
9191
}
9292

@@ -98,11 +98,17 @@ private function checkIsFriend($toUserId)
9898
*/
9999
private function addApplyData($toUserId, $greetings)
100100
{
101+
if (empty($greetings)) {
102+
$greetings = "";
103+
} else {
104+
$greetings = trim($greetings);
105+
}
106+
101107
try {
102108
$data = [
103109
"userId" => $this->userId,
104110
"friendId" => $toUserId,
105-
"greetings" => trim($greetings),
111+
"greetings" => $greetings,
106112
"applyTime" => ZalyHelper::getMsectime(),
107113
];
108114
$this->ctx->SiteFriendApplyTable->insertApplyData($data);
@@ -112,9 +118,12 @@ private function addApplyData($toUserId, $greetings)
112118
"friendId" => $toUserId,
113119
];
114120
$data = [
115-
"greetings" => trim($greetings),
116121
"applyTime" => ZalyHelper::getMsectime(),
117122
];
123+
124+
if (isset($greetings)) {
125+
$data['greetings'] = $greetings;
126+
}
118127
$this->ctx->SiteFriendApplyTable->updateApplyData($where, $data);
119128
}
120129
}

src/controller/Api/Friend/Api_Friend_ApplyListController.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* Time: 6:12 PM
77
*/
88

9-
class Api_Friend_ApplyListController extends BaseController
9+
class Api_Friend_ApplyListController extends BaseController
1010
{
11-
private $classNameForRequest = '\Zaly\Proto\Site\ApiFriendApplyListRequest';
11+
private $classNameForRequest = '\Zaly\Proto\Site\ApiFriendApplyListRequest';
1212
private $classNameForResponse = '\Zaly\Proto\Site\ApiFriendApplyListResponse';
1313

1414
public function rpcRequestClassName()
@@ -23,24 +23,25 @@ public function rpcRequestClassName()
2323
public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf\Internal\Message $transportData)
2424
{
2525
///处理request,
26-
$tag = __CLASS__ .'-'.__FUNCTION__;
27-
try{
26+
$tag = __CLASS__ . '-' . __FUNCTION__;
27+
try {
2828
$offset = $request->getOffset() ? $request->getOffset() : 0;
29-
$count = $request->getCount() && $request->getCount()< $this->defaultPageSize ? $request->getCount() : $this->defaultPageSize;
29+
$count = $request->getCount() && $request->getCount() < $this->defaultPageSize ? $request->getCount() : $this->defaultPageSize;
3030
$list = $this->getApplyList($offset, $count);
3131
$totalCount = $this->getApplyListCount();
3232
$response = $this->getApiFriendApplyListResponse($list, $totalCount);
3333
$this->setRpcError($this->defaultErrorCode, "");
3434
$this->rpcReturn($transportData->getAction(), $response);
35-
}catch (Exception $ex) {
36-
$this->ctx->Wpf_Logger->error($tag, "error_msg=".$ex->getMessage());
35+
} catch (Exception $ex) {
36+
$this->ctx->Wpf_Logger->error($tag, "error_msg=" . $ex->getMessage());
37+
$this->setRpcError("error.alert", $ex->getMessage());
3738
$this->rpcReturn($transportData->getAction(), new $this->classNameForResponse());
3839
}
3940
}
4041

4142
private function getApplyList($offset, $count)
4243
{
43-
$list = $this->ctx->SiteFriendApplyTable->getApplyList( $this->userId, $offset, $count);
44+
$list = $this->ctx->SiteFriendApplyTable->getApplyList($this->userId, $offset, $count);
4445
return $list;
4546
}
4647

@@ -55,7 +56,7 @@ private function getApiFriendApplyListResponse($list, $count)
5556
$response = new \Zaly\Proto\Site\ApiFriendApplyListResponse();
5657
$applyUserProfileList = [];
5758

58-
if($list) {
59+
if ($list) {
5960
foreach ($list as $user) {
6061
$publicUser = $this->getPublicUserProfile($user);
6162
$applyUserProfile = new \Zaly\Proto\Core\ApplyUserProfile();

src/controller/Api/Friend/Api_Friend_SearchController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf
2929
$offset = $request->getOffset();
3030
$count = $request->getCount(); // default 20
3131

32-
$this->ctx->Wpf_Logger->info("api.friend.search", "=================" . $request->serializeToJsonString());
32+
$this->ctx->Wpf_Logger->info("api.friend.search", "request=" . $request->serializeToJsonString());
3333

3434
$response = new \Zaly\Proto\Site\ApiFriendSearchResponse();
3535

src/controller/Api/Passport/Api_Passport_PasswordUpdateInvitationCodeController.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,23 @@ public function updateUserInfo($preSessionId, $invitationCode, $sitePubkPem)
6363
try{
6464
$userInfo = $this->ctx->PassportPasswordPreSessionTable->getInfoByPreSessionId($preSessionId);
6565

66-
$this->ctx->BaseTable->db->beginTransaction();
67-
6866
if($userInfo == false) {
6967
throw new Exception("preSessionId for update is null");
7068
}
7169
$userId = $userInfo['userId'];
72-
$updateData = [
73-
"invitationCode" => $invitationCode,
74-
];
75-
$where = ["userId" => $userId];
7670

77-
$this->ctx->PassportPasswordTable->updateUserData($where, $updateData);
71+
$userInfo = $this->ctx->PassportPasswordTable->getUserByUserId($userId);
72+
73+
$this->ctx->BaseTable->db->beginTransaction();
74+
75+
if($userInfo['invitationCode'] != $invitationCode) {
76+
$updateData = [
77+
"invitationCode" => $invitationCode,
78+
];
79+
$where = ["userId" => $userId];
80+
81+
$this->ctx->PassportPasswordTable->updateUserData($where, $updateData);
82+
}
7883

7984
$newPreSessionId = ZalyHelper::generateStrId();
8085

src/controller/Api/Plugin/Api_Plugin_ListController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ private function buildApiPluginListResponse($sessionId, $pluginList, $pluginPubl
102102
$pluginProfile->setId($plugin['pluginId']);
103103
$pluginProfile->setName($plugin['name']);
104104
$pluginProfile->setLogo($plugin['logo']);
105+
106+
$pluginProfile->setUsageTypes([$plugin['usageType']]);
105107
if ($plugin['sort']) {
106108
$pluginProfile->setOrder($plugin['sort']);
107109
} else {

src/controller/Api/Session/Api_Session_VerifyController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf
5353
$this->rpcReturn($transportData->getAction(), $response);
5454
} catch (Exception $ex) {
5555
$this->ctx->Wpf_Logger->info($tag, " error_msg=" . $ex->getMessage());
56+
$this->setRpcError("error.alert", $ex->getMessage());
5657
$this->rpcReturn($transportData->getAction(), new $this->classNameForResponse());
5758
}
5859
}

src/controller/Api/Site/Api_Site_ConfigController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ private function buildRandomBase64($random, $siteIdPrikBase64)
160160

161161
/**
162162
* 生成 transData 数据
163+
* @param $scheme
163164
* @param $host
164165
* @param $port
165166
* @param $configData
@@ -175,6 +176,10 @@ private function buildSiteConfigResponse($scheme, $host, $port, $configData, $is
175176
$scheme = "http";
176177
}
177178

179+
if (empty($port)) {
180+
$port = 80;
181+
}
182+
178183
////ApiSiteConfigResponse 对象
179184
$response = new ApiSiteConfigResponse();
180185

src/controller/Im/Cts/Im_Cts_MessageController.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ private function returnMessage($msgId, $msgRoomType, $msgType, $message, $fromUs
9999
//send friend news
100100
$this->ctx->Message_News->tellClientNews($this->isGroupRoom, $this->toId);
101101

102-
//send push to friend
103-
$pushText = $this->getPushText($msgType, $message);
102+
if ($result) {
103+
//send push to friend
104+
$pushText = $this->getPushText($msgType, $message);
104105

105-
$this->ctx->Push_Client->sendNotification($msgRoomType, $msgType, $fromUserId, $this->toId, $pushText);
106+
$this->ctx->Push_Client->sendNotification($msgRoomType, $msgType, $fromUserId, $this->toId, $pushText);
107+
}
106108
}
107109

108110
private function returnU2MessageIfNotFriend($msgId, $msgRoomType, $fromUserId, $toUserId)
@@ -162,6 +164,10 @@ private function checkIsGroupMember($userId, $groupId)
162164
// check u2-message if lawful
163165
private function getIsFriendRelation($userId, $friendUserId)
164166
{
167+
if ($userId == $friendUserId) {
168+
return false;
169+
}
170+
165171
$tag = __CLASS__ . "->" . __FUNCTION__;
166172
try {
167173
$isFriend = $this->ctx->SiteUserFriendTable->isFriend($userId, $friendUserId);
@@ -170,7 +176,7 @@ private function getIsFriendRelation($userId, $friendUserId)
170176
} catch (Exception $e) {
171177
$this->ctx->Wpf_Logger->error($tag, $e);
172178
}
173-
return true;
179+
return false;
174180
}
175181

176182
/**

0 commit comments

Comments
 (0)