🐛 Fix create duplicate relationship
This commit is contained in:
parent
a08372d4d2
commit
497c0692ca
2
.idea/dataSources.local.xml
generated
2
.idea/dataSources.local.xml
generated
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="GO-243.23654.166">
|
||||
<component name="dataSourceStorageLocal" created-in="GO-243.24978.59">
|
||||
<data-source name="hy_passport@localhost" uuid="74bcf3ef-a2b9-435b-b9e5-f32902a33b25">
|
||||
<database-info product="PostgreSQL" version="16.4 (Homebrew)" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.6.0" dbms="POSTGRES" exact-version="16.4" exact-driver-version="42.6">
|
||||
<identifier-quote-string>"</identifier-quote-string>
|
||||
|
15
.idea/workspace.xml
generated
15
.idea/workspace.xml
generated
@ -4,9 +4,10 @@
|
||||
<option name="autoReloadType" value="ALL" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":recycle: Replace i18n services with nexus one">
|
||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":necktie: No longer return error when trying add a member who already in the realm">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/notifications.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/relationships.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/relationships.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -117,8 +118,8 @@
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-gosdk-d297c17c1fbd-85c80fddc9a6-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-243.23654.166" />
|
||||
<option value="bundled-js-predefined-d6986cc7102b-822845ee3bb5-JavaScript-GO-243.23654.166" />
|
||||
<option value="bundled-gosdk-d297c17c1fbd-57c114c3cede-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-243.24978.59" />
|
||||
<option value="bundled-js-predefined-d6986cc7102b-76f8388c3a79-JavaScript-GO-243.24978.59" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
@ -159,8 +160,6 @@
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<MESSAGE value=":sparkles: Better relationships stauts query" />
|
||||
<MESSAGE value=":truck: Move make friendship api" />
|
||||
<MESSAGE value=":boom: Move remove member api arguments from body to querystring just as messaging" />
|
||||
<MESSAGE value=":bug: Hotfix previous commit compile issue" />
|
||||
<MESSAGE value=":sparkles: Add realm member support both account name and id" />
|
||||
@ -184,7 +183,9 @@
|
||||
<MESSAGE value=":sparkles: Register with preferred language" />
|
||||
<MESSAGE value=":necktie: Limit max auth steps to 2 for normal users" />
|
||||
<MESSAGE value=":recycle: Replace i18n services with nexus one" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value=":recycle: Replace i18n services with nexus one" />
|
||||
<MESSAGE value=":bug: Fix inconsistent remove member behaviour with messaging" />
|
||||
<MESSAGE value=":necktie: No longer return error when trying add a member who already in the realm" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value=":necktie: No longer return error when trying add a member who already in the realm" />
|
||||
<option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" />
|
||||
</component>
|
||||
<component name="VgoProject">
|
||||
|
@ -112,6 +112,20 @@ func NewFriend(userA models.Account, userB models.Account, skipPending ...bool)
|
||||
Status: models.RelationshipPending,
|
||||
}
|
||||
|
||||
var dupeCount int
|
||||
if rel, err := GetRelationWithTwoNode(userA.ID, userB.ID, true); err == nil {
|
||||
relA = rel
|
||||
dupeCount++
|
||||
}
|
||||
if rel, err := GetRelationWithTwoNode(userB.ID, userA.ID, true); err == nil {
|
||||
relB = rel
|
||||
dupeCount++
|
||||
}
|
||||
|
||||
if dupeCount > 1 {
|
||||
return relA, fmt.Errorf("unable to recreate a relationship with that user")
|
||||
}
|
||||
|
||||
if len(skipPending) > 0 && skipPending[0] {
|
||||
relA.Status = models.RelationshipFriend
|
||||
relB.Status = models.RelationshipFriend
|
||||
|
Loading…
x
Reference in New Issue
Block a user